Deezer Artists TOP songs method, same token, different answers - deezer

This call
http://api.deezer.com/2.0/artist/4762/top?output=xml&limit=30&access_token=...
executed via server gives me two different lists of songs if it is executed from a USA server OR from a Spanish server.
I have been told that, using a PREMIUM token, the API should answer according to the country of the user, but in this case it doesn't happen (the token belongs to the same premium user).
These are the songs (id) I get from US:
1016021
74440163
74254892
72545071
1016005
74254893
74254895
73945040
1016003
74254894
73945037
74254896
73945038
64820753
73945039
73945045
64820745
16880921
73945041
64820747
73945042
64820750
1016023
73945043
73945046
73945044
64820746
7511353
73945047
64820755
these are the ones I get from spain
74440163
74254892
73945036
74254893
73945040
74254895
74254894
73945037
73945038
74254896
73945039
64820753
73945045
64820745
64820756
73945041
16880921
64820747
73945042
64820750
73945043
73945044
73945046
64820746
7511353
73945047
64820755
64820748
64820757
16881228
Also strange is that if, from the US server, I try to get info about the first song retrieved
http://api.deezer.com/2.0/track/1016021/?access_token=...
The API says that the song is not readable; can a "not-readable" song be in the top 30?

As far as I know your account should be Premium+ to get still the same content regardless of your location.

Related

Facebook Server-Side API - push custom events to create Custom Audience

We try to use Server-Side API to push custom events to our pixel in order to create event-based Custom Audiences in Facebook Ads (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/)
We use _fbp cookie value to match users (it's a first party cookie created on our website by FB pixel).
For example (Python):
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adspixel import AdsPixel
my_app_id = 'X'
my_app_secret = 'X'
my_access_token = 'X'
my_pixel_id = 'X'
FacebookAdsApi.init(access_token=my_access_token, app_id=my_app_id, app_secret=my_app_secret)
fields = []
params = {
'data': [{'event_name': 'icrm_test_20191113_fbp_1m', 'event_time': 1573230217, 'user_data':{'fbp': 'fb.1.1558571054389.1098115397'}}]
}
print(AdsPixel(my_pixel_id).create_event(fields=fields, params=params))
The problem is, when we create a Custom Audience in Facebook Ads, the size of the list is always < 1000, even if we push hundreds of thousands of cookie IDs, which means Facebook matched a very low % of cookies, which were sent.
Custom Audience definition based on server-side event:
List size is always <1000, no matter how many fbp cookies are sent:
It seems like there is some kind of an issue matching _fbp cookies to Facebook user profiles. Is there any known way of improving/fixing matching results? We can't use hashes of sensitive data.
External_id matching (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/parameters) also gave us similar results.
The event time you are using there translates to 11/08/2019 # 4:23pm (UTC).
So they're not gonna get included in your 30 day window.
Try importing time
import time
Then set
'event_time': int(time.time())

Get follower count on Scratch (API)

I am looking to find the follower count of a Scratch user using the Scratch API. I already know how to get their message count, with https://api.scratch.mit.edu/users/[USER]/messages/count/.
This answer targets the Scratch REST API, documented here.
You get the user's followers by requesting them: https://api.scratch.mit.edu/users/some_username/following where some_username is to be replaced by the actual username.
This will return 0 to 20 results (20 is the default limit of objects returned by the REST API). If there's less than 20 results, then you're done. The amount of followers is simply the count of the objects returned.
If there's 20 objects returned, we can't be certain we've requested all the user's friends as there might be more to come. Therefore, we skip the first 20 followers of that user by supplying the ?offset= parameter: https://api.scratch.mit.edu/users/some_username/following?offset=20
This retrieves the second 'page' of friends. Now we simply loop through the procedure described above, incrementing offset by 20 each time until either less than 20 results are returned or no results are returned. The amount of friends of that user is the cumulative count of the objects returned.
As mentioned by _nix on this forum thread, there is currently no API to achieve this. However, he/she rightly points out that the number can be obtained from a user's profile page.
You may write a script (in JavaScript, for example) to parse the HTML and get the follower count in the brackets at the top of the page.
Hope this helps!
There is a solution in Python:
import requests
import re
def followers(self,user):
followers = int(re.search(r'Followers \(([0-9]+)\)', requests.get(f'https://scratch.mit.edu/users/{user}/followers').text, re.I).group(1))
return f'{followers} on [scratch](https://scratch.mit.edu/users/{user}/followers)'
Credit goes to 12944qwerty, in his code (adapted to remove some implementation specific stuff).
use ScratchDB
var user = "username here";
fetch(`https://scratchdb.lefty.one/v3/user/info/${user}`).then(res => res.json()).then(data => {
console.log(`${user} has ` + data["followers"].toString() + " followers");
}
(Edit: this is javascript btw, I prefer Python but Python doesn't have a cloud.set function and this is how I did it)
Use ScratchDB (I used httpx, but you can GET with anything):
import httpx
import json
user = "griffpatch"
response = httpx.get(f"https://scratchdb.lefty.one/v3/user/info/{ user }")
userData = json.loads(response.text)
followers = userData["statistics"]["followers"]
https://api.scratch.mit.edu/users/griffpatch/followers
this gives the follower names, scratch staus(scratch team or not), pfp, everything in their profile

Facebook share count from debugger page

How can I get number of shares that is shown on facebook debugger page via API?
I've empirically found it to fit the most for comparing with share counters from some others social networks, but it looks like this number does not show up anywhere except that debugger page.
Here are some details.
By now I've found 3 API calls that return somewhat relevant data:
via graph API: http://graph.facebook.com/?id=http%3A%2F%2Farzamas.academy%2Fspecial%2Fruslit
via FQL: https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url=%27http%3A%2F%2Farzamas.academy%2Fspecial%2Fruslit%27
via some old API: https://api.facebook.com/method/links.getStats?urls=http%3A%2F%2Farzamas.academy%2Fspecial%2Fruslit&format=json
The values in second and third call are identical, for my test url http://arzamas.academy/special/ruslit the current ones are
share_count: 492, like_count: 5042, comment_count: 491, total_count: 6025
The counter from the first call is named shares and is equal to total_count from second and third call.
When you paste the url in facebook debugger and click 'Show existing scrape information', one of the first rows in table is
Canonical URL: http://arzamas.academy/special/ruslit (6025 likes, 1635 shares)
Number of likes is equal to total_count from API calls, but how can I get that 1635 shares number via API?
I've found that specifying Graph API version newer than 2.0 gives another number (share.share_count), for some reason it is the sum of both numbers, that are shown in debugger (likes + shares).
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=%3Fid%3Dhttp%253A%252F%252Farzamas.academy%252Fspecial%252Fruslit&version=v2.3&
So now I can get counters from two calls and subtract to get the value that I need. There are obvious cons for this method:
2 calls
token requirement
looks not very reliable
But it should work, I'll try to implement it and will mark this answer as correct if there are no additional caveats and until there is no better solution.

Facebook Graph API event-id/comments?since=2014-02-01&until=2014-02-10 , Date filter has no effect

I am trying to bring comments made on a particular event by targeting this URL: https://graph.facebook.com/1466384840257158/comments
I am passing the user_access_token
I have two comments at present on this event made on the same
day(2014-03-29)
Now I try to pass a date which should bring an empty data result/object
like this: https://graph.facebook.com/1466384840257158/comments?since=2011-01-01&until=2014-01-10
This request has no effect, it still shows me the two comment made
on the 29th
I have tried the same kind of date range on my user-id/feed and it
gave me an empty data object.
Finally i tried event-id/feed (before trying date filter) and it
gave me the following error
.
{
"error": {
"message": "An unexpected error has occurred. Please retry your request later.",
"type": "OAuthException",
"code": 2
}
}
Could you please guide me about date filter on that particular query (point4) or if you have any other idea to use date filter on comments made for an event.
Comments use Cursor-based Pagination, so you cannot use since or until on the comments endpoint (these parameters would work f.ex. for the feed endpoint).
To get the comments in a time range you have to fetch all comments from NOW to the start of the time range, f.ex. with https://graph.facebook.com/1466384840257158/comments?filter=stream&limit=1000+paging (the filter=stream will order the result with the timestamp).
USING SINCE UNTIL FOR COMMENTS on GROUP
If you want to use since and until for comments, it is not possible directly for a group. So, First you can apply it for status(feed) and then get the comments for that feed.
This works for me:
{group_id}/?fields=feed.since(08/25/2016).until(08/31/2016){from,comments{from,message}}
Why don't you try first to filter by notifications?... notifications allows you to add parameters like since. For example (using Facebook pages):
https://graph.facebook.com/PAGEID?fields=notifications.since(2015-3-31 00:00:00).limit(250).include_read(true)&{id,created_time,updated_time,unread,object,link}&access_token=ACCESSTOKEN
Once you got the json data, loop through data, get the ID and send a second request but this time using the PAGEID_POSTID edge. Something like this:
https://graph.facebook.com/PAGEID_POSTID/comments?fields=id,from{name,id},message,can_remove,created_time&limit=1000
Voahla!... there's no need to read every comment!...
Note 1: A Page access token is required, along with the manage_pages permission
Note 2: Use the parameter/field include_read to get all the notifications, even the already readed
Note 3: In the second request, use the parameter/field "filter=stream" to order the posts and get the comments made in the name of your page
Note 4: Don't forget to control the asynchronicity once you loop!
Note 5: Notifications duplicate posts, use an array to avoid to read more than one time the postUse the parameter/field include_read to get all the notifications, even the already readed
I do not know if it's too late. But, Yeah it works in the graph api version 3.3.
for example: if you wanna get comments on a post of a Facebook page you can do it like this:
You have to use page Access-token
The get Graph Request : post_id/comments?since=some_date

Retrieve User ID of Facebook App Invitor

In the context of a given Facebook app, suppose User A invited user B to start using it. Once User B accepts to use the app, is there any way to retrieve the ID of User A programmatically (via either PHP/JS SDK) ? This doesn't seem quite documented.
For what it's worth, A/B users are friends, if it's any use.
when user comes following the app request, you can get request id's using
$_GET['request_ids']
then retrieve all the request ids with which you can call graph api to get the corresponding request details like below:
if(isset($_GET['request_ids']))
{
$request_ids = $_GET['request_ids'];
}
$request_ids = explode(",", $request_ids);
foreach($request_ids as $request_id)
{
$request_object = $facebook->api($request_id);
//this $request_object have sender facebook id in the field uid_from
}
If you look here:
http://developers.facebook.com/docs/reference/dialogs/requests/
You can see the object layout. Of note is the data property:
Optional, additional data you may pass for tracking. This will be
stored as part of the request objects created. The maximum length is
255 characters.
In this object you can add your referring UserId and then when the request is claimed, you can then process it on your end.
Hope this helps.