How can I get user history between two dates with deezer API? - deezer

I would like to get user history between two dates (get history for one month for example). Is there a way to add param in url ? something like :
http://api.deezer.com/user/me/history?start=1483522674&end=1483609074
Thanks

Unfortunately, it is not possible, but instead you can use the "limit" and "index" parameters.

Related

Facebook Graph API (v.3.1) Marketing API: use two paramaters with Campaign Insights

I'm trying to return campaign insights in the Facebook Marketing API and show the results aggregated for each day and broken down by country.
I'm trying
act_xxxx/?fields=campaigns{name,insights}&time_increment=1&breakdowns=country
but the country and time_increment paramaters don't seem to affect the results.
I've had success with EITHER time_increment of breakdowns if I don't use the ?fields paramater but then I'm not aggregating at the level I want and can still only use one paramater.
Can anyone suggest anything?
Thanks
James
Managed to figure this one out:
act_xxx/insights?fields=account_name,campaign_name,date_start,date_stop,spend,reach,impressions,cpc,inline_link_clicks,frequency,ctr,cost_per_inline_link_click,inline_link_click_ctr&breakdowns=country&time_increment=1&level=campaign
The key things I was missing were:
define the level of aggregation in the ?level paramater return the
Return insights edge before the ?fields paramater rather than through field
extension as I did in my example.
all you have to do is
act_xxxx?fields=campaigns{name,insights.time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country)}
This one fetches all campaigns name and insights between the date interval in day by day manner breaking down according to countries
you can use {} for subfields like
campaigns{ads{name,insights,adcreatives{image_url}}}
you can use . and () for parameters like; always make sure you use you use fields only after parameters like this order .(){}
campaigns.limit(1).time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country){ads{name,insights.time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country),adcreatives{image_url}}}

Facebook Marketing API: Is it possible to filter insights by status

I am trying to filter adsets insights by adset status, but when I add a status filter, I get an empty dataset back:
curl "https://graph.facebook.com/v2.7/act_<redacted>/insights?fields=clicks,impressions,cpc,ctr,account_id&time_range%5Bsince%5D=2016-01-12&time_range%5Buntil%5D=2016-09-12&access_token=<redacted>&format=json&filtering=%5B%7B%22field%22:%22status%22,%22operator%22:%22EQUAL%22,%22value%22:%22ACTIVE%22%7D%5D&level=adset"
here is what filtering param looks like before it gets url-encoded:
[{"field":"status","operator":"EQUAL","value":"ACTIVE"}]
I have tried all valid values for status ACTIVE, PAUSED, DELETED, ARCHIVED to no avail.
When I remove filtering param - I see my data.
The question is:
Does anyone know if it is possible to filter by status, and if it is, what I am doing wrong?
It is possible. Using latest version as of March 2018.
You need to actually request all the ads that are ACTIVE and then provide insights as a 'nested' list of fields.
Replace 123456 with your ad account (but leave the 'act_' which is needed)
act_123456/ads?fields=effective_status,name,insights{total_action_value,total_actions,actions},adset_id,campaign_id&filtering=[{'field':'effective_status','operator':'IN','value':['ACTIVE']}]
This also works for /campaigns and /adsets
You can also do this (be sure to include &level=ad):
act_123456/insights?fields=ad_id,adset_id,campaign_name,action_values,campaign_id,total_action_value&level=ad&filtering=[{"field":"campaign.delivery_info","operator":"IN","value":["active"]}]
Filtering by insights isn't possible. At least in v2.7. To get insights for let's say ads I've decided to do the following:
1. Fetch ads that I need via /ads call. This allows me to filter by status.
2. Fetch insights for the same collection of ads and make sure that I ad id is included in the response.
3. Filter the second collection using the first one.
i m using this to filter campaigns with insights , working for me , start playing with it
'filtering'=>
array(
array(
"field"=>"campaign.effective_status",
"operator"=>"IN",
"value"=>$campaigncheckstatus,
),
),
$campaigncheckstatus = array("ACTIVE","PAUSED");
dont forget to json_encode $campaigncheckstatus if passed through url

Instagram Search for a tag within particular date range

I am looking to retrieve results from instagram for a particular tag mytag , I tried using this API call,
https://api.instagram.com/v1/tags/{tag-name}/media/recent
but it only returned 33 results even though there are more results. This question can be considered an extension to this question: How To Search Instagram via API Query?
What is the way to return instagram results for a particular tag within a date range?
This may be done through the min_tag_id and max_tag_id which. Not sure how to convert my date time to min_tag_id or max_tag_id?
call the API with max_tag_id and min_tag_id like this:
https://api.instagram.com/v1/tags/{tag-name}/media/recent?client_id={CLIENT_ID}&max_tag_id=1378677250000000&min_tag_id=1375998850000000
max_tag_id and min_tag_id is epoch_time + "000000"
you still only get 20 per API call, use pagination to get all
Update: Instagram changed the tag_id, so date filter cannot be done
this way. Login on http://gramfeed.com and search for a hashtag and
you can do date/time filter, its a different hack implementation.

Proper REST formatted URL with date ranges

I have a REST URL to get all users formatted like this:
http://example.com/users
To get an individual user by id:
http://example.com/users/12345
To get all user's bids:
http://example.com/users/12345/bids
To get all user's bids between two dates:
http://example.com/users/12345/bids/?start=01/01/2012&end=01/31/2012
or should it be like this:
http://example.com/users/12345/bids/start/01012012/end/01312012
I'm leaning towards the 1st date range URL as start and end are not entities in the domain. What is the proper way to format a REST URL with a date range?
Thanks,
Tom
http://example.com/users/12345/bids?start=01-01-2012&end=01-31-2012
Have the query parameters on the same "level" as the bids (remove the slash before the question mark). But you would probably want to have support for if they only provide one query parameter. So if they only provided "start" then it would get all bids after that date, or if they only provided "end" it would get all bids before that date.
The reasoning being that query parameters are good for GETting a subset of results from a GET request. They don't go on another level because the next level is usually one specific item with a unique identifier.
I would go with http://example.com/users/12345/bids?start=2012-01-01&end=2012-01-31.
There shouldn't be a slash before the query string.
Avoid using slashes in the query string. It'll be easier that way.
If you use the path separator / to delimit the values you're likely to encounter numerous issues. If you decide you want the start and end dates to allow ISO formats e.g. 2021-10-12T01:00:00.000Z, 2021-10-01T18:00:00.000+05:00, those formats contain characters that will break the URL. Much better to use querystring parameters.
I'd recommend using the querystring and ISO format for dates so your URL will look something like this:
https://example.com/users/12345/bids?start=2022-08-08T00:00:00.000Z&end=2022-08-09T00:00:00.000Z
Your API method that retrieves by date range can then be differentiated from the GET request that retrieves all bids for the user, simply by using a different method signature that expects additional start and end date parameters in the request.
if example.com/users/12345 gets the user with id 12345, then to get all users by id it should be example.com/users with the id included in the response as a relationship. (usually a hyperlink to that resource).
Now to get them by date ranges it should be example.com/users/start=01-01-2012&end=01-31-2012
The 12345 part is the id of an individual user, it's a resource, therefore it should not be included to get the rest of the users.
As the name of the parameter it should be meaningful. start could mean anything, but start_date is more meaninful.

"sex" field in Users.getInfo in Facebook API

This is a noob question. According to Facebook API documentation, the sex field in Users.getInfo() function returns values based on users' locale. Hence, determine the gender of user is difficult.
Any solution suggested?
1) This isn't an elegant solution, and perhaps there's a better way that uses the API, but what if you manually created a look-up table for different values of 'sex' in different locales? You could try checking out facebook profiles of people from different countries and get the string displayed for their sex. Then, put that into some kind of dictionary data structure that allows you to grab the M-F string pair based on the locale's code (also given by getInfo()). For example en-US => (male, female), ja-JP => (男性, 女性). Of course, you could try using google translate too. After you gathered this data for a handful of the main locales, you'd be more-or-less covered. Maybe someone on the internets already has done it.
Of course, you could try emailing someone who works on the API for these values. The list of locale codes is here http://wiki.developers.facebook.com/index.php/Facebook_Locales .
2) Here is probably a better solution than (1). If you directly query the FQL User table, the value returned in 'sex' will always be English, starting from February 7 2010. More information about that is here: http://wiki.developers.facebook.com/index.php/User_%28FQL%29 . So, perhaps in the future getInfo() will return only English too. Who knows.
3) The answer to your question is also given on this existing post: Facebook FQL user table `sex` field : how to return male/female even the user is using different locale?