Query problems with Twitter search API - api

I'm building Twitter Search API query based on their instructions here and here.
The query is working fine if I use the exact examples of the instructions above, like if I send the query like this: q=%23superbowl&result_type=recent, it would give me as many answers I'd like to get
BUT
if I would try to search for hashtag jäniksenvuosi (which I know to be tweeted many times), I would only get one answer and that answer is my own latest tweet. Nothing else.
I tried it with other Finnish words with umlauts too, but those work properly, so it is not about umlauts either.
Question in short
What's the difference between these two and how do I fix this?
Working: q=%23superbowl&result_type=recent
Not working: q=%23j%C3%A4niksenvuosi&result_type=recent
Search metadata
superbowl:
[search_metadata] => Array
(
[completed_in] => 0.075
[max_id] => 688984569614327808
[max_id_str] => 688984569614327808
[next_results] => ?max_id=688976241051873280&q=%23superbowl&count=30&include_entities=1&result_type=recent
[query] => %23superbowl
[refresh_url] => ?since_id=688984569614327808&q=%23superbowl&result_type=recent&include_entities=1
[count] => 30
[since_id] => 0
[since_id_str] => 0
)
jäniksenvuosi
[search_metadata] => Array
(
[completed_in] => 0.052
[max_id] => 688984569614327808
[max_id_str] => 688984569614327808
[query] => %23j%C3%A4niksenvuosi
[refresh_url] => ?since_id=688984569614327808&q=%23j%C3%A4niksenvuosi&result_type=recent&include_entities=1
[count] => 30
[since_id] => 0
[since_id_str] => 0
)

Just tried this using twurl, and I currently get three results for that hashtag (#jäniksenvuosi).
This is consistent with what I'd expect. On the Twitter website, there are three Tweets returned that contained that hashtag during January. The previous occurrence was in December.
Twitter's Search API has access to an index of Tweets covering approximately 7 days, and it is optimised for recency rather than completeness (see this page in the developer documentation)

Related

eBay Finding API get completed listings sort by whether ended with sales

Trying to get completed listings with sales from eBay API. I can get the list of all 'ended listings', however, having troubles determining, whether the listing had any sales. What I am currently using to determine it is
item->sellingStatus->sellingState;
even though according to eBay API documentation that is exactly what I need, the response never matches manual search on eBay..
If an item is listed as good til cancelled and it had sales, but is still running (and will be running continuously), the response for this listing is EndedWithoutSales, which makes no sense - first of all, it is not ended yet, second of all, it already had sales..
What I need is a reliable way to sort completed listings into those listings, which had at least one sale (regardless whether the listing is still running as good til cancelled or already ended) and those listings, which ended with no sales.
Any ideas?
I am using GetMyeBaySellingRequest to get my sale numbers i.e last 24 hours ended listings which are sold.
<SellingSummary><Include>TRUE</Include></SellingSummary>
<SoldList>
<DurationInDays>1</DurationInDays>
<OrderStatusFilter>All</OrderStatusFilter>
<Pagination>
<EntriesPerPage>100</EntriesPerPage>
<PageNumber>1</PageNumber>
</Pagination>
</SoldList>
Hence under the SellingSummary part i received all the required data. Here [TotalSoldCount] depends on the SoldList > DurationInDays.
[ActiveAuctionCount] => 56
[AuctionSellingCount] => 13697
[AuctionBidCount] => 59
[TotalAuctionSellingValue] => 724.44
[TotalSoldCount] => 32
[TotalSoldValue] => 477.97
[SoldDurationInDays] => 1
[ClassifiedAdCount] => 0
[TotalLeadCount] => 0
[ClassifiedAdOfferCount] => 0
[TotalListingsWithLeads] => 0
[QuantityLimitRemaining] => 54852
[AmountLimitRemaining] => 4.845525842E7
Hope it helps.

How to prioritize complete sentences instead of single search terms?

In my CloudSearch instance I want to give a greater priority to complete phrases instead of just word counts.
An example would be, when I search for "foo bar" I would like documents that have "foo" and "bar" next to each other be scored better than documents that have the two terms scatterred in the document. Of course, any other document containing either words should retrieved but not scored as highly.
Any ideas of how the query could be done ?
$searchQuery = array(
'query' => "(or ".$searchParam." (phrase boost=10 ".$searchParam."))",
'queryParser' => 'structured',
'queryOptions' => json_encode(array('defaultOperator' => 'or'))
);
This worked to some extend.
Totally random boosting value.

Get all applications in Podio

I would like to get all apps which are accessible to me. So I used the API
https://developers.podio.com/doc/applications/get-all-apps-5902728
There is a 'limit' parameter but there is no 'offset' parameter.
The max value of limit is 100.
Is there any other method to get all apps?
Any help will be appreciated.
You can still go through hierarchy Org => Space => App => Item
Get all organisations, which will also give all spaces
https://developers.podio.com/doc/organizations/get-organizations-22344
Get all apps per space
https://developers.podio.com/doc/applications/get-apps-by-space-22478
Small example in Ruby demonstrating how it works
orgs = Podio::Organization.find_all()
orgs.each do |org|
org.spaces.each do |space|
puts "Working in space id:#{space['space_id']} name:'#{space['name']}'"
apps = Podio::Application.find_all_for_space(space['space_id'])
apps.each do |app|
puts "\tApp id:#{app['app_id']} name:'#{app['config']['name']}'"
end
end
end

Error using metrics listed in Google's Metrics and dimensions

I am using this code to query the api
function getResults(&$analytics, $profileId) {
// Calls the Core Reporting API and queries for the number of sessions
// for the last 30 days.
return $analytics->data_ga->get(
'ga:' . $profileId,
'30daysAgo',
'today',
'ga:sessionCount,ga:sessionDurationBucket,ga:users,ga:percentNewSessions,ga:bounceRate,ga:pageviews');
}
i get this error upon executing the code
Fatal error: Uncaught exception 'Google_Service_Exception' with
message 'Error calling GET
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A114460017&start-date=30daysAgo&end-date=today&metrics=ga%3AsessionCount%2Cga%3AsessionDurationBucket%2Cga%3Ausers%2Cga%3ApercentNewSessions%2Cga%3AbounceRate%2Cga%3Apageviews:
(400) Unknown metric(s): ga:sessionCount, ga:sessionDurationBucket
anyone ever experience? I do not understand why it does not recognize those metrics when it is listed
https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=user&jump=ga_sessioncount
If you look more closely into that documentation you will see that session count is not a metric, it's a dimension. The reason is that you want to be able to do breakdowns of metrics by session count (e.g. "show avg. duration of sessions for users with 3 sessions") and for that you need categorical data.
Even if you overlook the (not particularly distinctive) column heading in the table of contents (ga:sessionCount is in the "dimensions"-column) the fact that the datatype is a string would be a dead giveaway. Metrics are always numbers. Dimensions are always strings, even if they sometimes look like numbers.
Same goes for ga:sessionDurationBucket.
Look at this example from the documentation to see how dimensions are passed into the query via an array that holds optional parameters:
private function queryCoreReportingApi() {
$optParams = array(
'dimensions' => 'ga:source,ga:keyword',
'sort' => '-ga:sessions,ga:source',
'filters' => 'ga:medium==organic',
'max-results' => '25');
return $service->data_ga->get(
TABLE_ID,
'2010-01-01',
'2010-01-15',
'ga:sessions',
$optParams);
}
You'd need to construct a similar $optParams array:
$optParams = array(
'dimensions' => 'ga:sessionCount,ga:sessionDurationBucket'
');
and pass it to your query:
return $analytics->data_ga->get(
'ga:' . $profileId,
'30daysAgo',
'today',
$optParams,
'ga:users,ga:percentNewSessions,ga:bounceRate,ga:pageviews');
}
and remove the dimensions from the list of metrics.
Btw. Google has a wonderful documentation page on the difference between dimensions and metrics and how they are used in the reports.

Grouping items into first occurances

I totally can't get my head around writing a correct query for my problem this morning so here's hoping that someone out there can help me out.
I have a database table called Sessions which basically looks like this
Sessions:
SessionID
SessionStarted
IPAddress
..other meta data..
I have a requirement where I am to show how many new Sessions (where new is defined as from a previously unseen IPAddress) arrive each day over a given period. Basically, each IPAddress should count only once in the results, namely for the day of the first session from the IPAddress. So I'm looking for a result like:
[Date] [New]
2009-10-01 : 11
2009-10-02 : 6
2009-10-03 : 19
..and so on
...which I can plot on some nice chart and show to important people. I would very much prefer a Linq2SQL query as that is what we are currently using for data access, but if I'm out of luck I may be able to go with some raw SQL (accessed via stored procedure, but I would really, really, really prefer Linq2SQL).
(As a bonus my next step will very likely be qualifying which sessions should be included by filtering on some of the other meta data)
Hoping that someone clever will help me out here...
I would use something like this.
var result = data.OrderBy(x => x.SessionStarted)
.GroupBy(x => x.IPAddress)
.Select(x => x.First())
.GroupBy(x => x.SessionStarted.Date)
.Select(x => new { Date = x.Key, New = x.Count() });