Deezer album chart API returns different results with access token - deezer

I noticed that I get a different response to the Deezer API album chart request when a valid access token is included in the request. Without access token I get the full results, but with it, I only get the first 14 results. Also, those 14 results don't match the first results of the full results.
Request without access token (using HTTPie):
http 'https://api.deezer.com/chart/462/albums'
Response:
{
...
"next": "https://api.deezer.com/chart/462/albums?index=10",
"total": 300
}
Request with access token (using HTTPie):
http 'https://api.deezer.com/chart/462/albums?access_token=frK...'
Response:
{
...
"next": "https://api.deezer.com/chart/462/albums?access_token=frK...&index=10",
"total": 14
}
So are the album chart results filtered according to the requesting user? If so, how and why? Is there any way to get unfiltered results using the Deezer JavaScript SDK DZ.api call (that automatically adds the access token)?

Actually, the token, as you should know, allows to identify the user. The rights (from the country, the label, the account...) according to the track are read in order to filter the availability of the tracks, that's why you can have different results with or without a token, even with 2 different tokens.
You can use DZ.api without login, so you will have only the results according to the current country. It adds automatically the token only if you're logged.

Related

How to display "from" fields in comments via Facebook Graph API

I would like to find the id (app-scoped) for someone who has posted a comment on a public page.
For example, I get a list of recent posts/comments on the NY Times page via:
v2.11/nytimes/feed?fields=comments.limit(10){message,created_time,from},name,message,from&limit=2
The data returned looks like this:
"comments": {
"data": [
{
"message": "Wouldn’t know. Not paying $13/mo for this.",
"created_time": "2017-12-10T05:57:18+0000",
"id": "10151412260164999_10151414049324999"
}
],
There is no from field. The same is also true if I attempt to view the comment directly using it's id with
v2.11/10151412260164999_10151414049324999?fields=from,message,created_time
I have tried using the Facebook Graph API Explorer, using both my User Token, as well as an App Token.
Since v2.11 of the Graph API, you need a Page Token to get user data of comments: https://developers.facebook.com/docs/graph-api/changelog/version2.11#gapi-90
User information will not be included in GET responses for any objects owned by (on) a Page unless the request is made with a Page access token. This affects all nodes and edges that return data for objects owned by a Page.
In other words: You can only get user information if you manage the Page.
Edit: Since the latests update in the Graph API, you have to get the App reviewed and you must go through Business Verification or Individual Verification. (thanx #Guiman04)
Please check whether you are using the accessToken for the page you are trying to get data from, i had same issue, and was resolved by using the correct accessToken for the page.

Facebook Graph API URL Scrape Inconsistent

I am running queries against Facebook Graph API to fetch OG meta information about URLs. Using a Facebook APP token, I can request most URLs and get their corresponding meta data back. But I have run into two issues that I can't find a solution for. I have one domain that refuses to pull any meta information using an APP token. Instead I get back an error 100 (Unsupported post request). But when I make the same request using a User Access Token, it works correctly. The second issue I found is that when a URL has any kind of OG error, Facebook is still scraping it, but will return a 100 error instead of returning the meta details (with both the app token and the user access token). I've even tried running the query without the scrape parameter, to no avail.
Normal Request That Returns Meta Fields of URL:
POST:
https://graph.facebook.com/v2.9/
{
"id": "http://viralcrunch.com/articles/22325/these-guys-invented-the-anti-smart-phone-and-it-will-blow-your-mind",
"scrape": "true"
}
Request That Returns 100 Unsupported post request Error W/ App Token
POST:
https://graph.facebook.com/v2.9/
{
"id": "http://turnthispage.com/dads-totally-winning-fatherhood/",
"scrape": "true"
}
Request That Returns 100 Invalid Object Error W/ Any Token
POST:
https://graph.facebook.com/v2.9/
{
"id": "http://www.thesportster.com/basketball/top-20-nba-players-who-live-life-to-the-fullest/",
"scrape": "true"
}
The second URL seems to be associated with an app id of an app that has some kind of access restrictions set; so I guess it is the same here as if you tried to access information about a Facebook Page that has access restrictions set - you can not query any details about those using the app access token, you need to use a user access token for a user that is allowed to see the content, or a page access token for that page.
And that you get an error response for the third one seems only natural. After all, this is a tool intended to debug and scrape the Open Graph objects you are in control of, so if the OG meta data is not in order it should return an error.

Facebook graph API {post-id}/likes returns empty data

This request returns an empty array: graph.facebook.com/773227196065108/likes, but this request returns a normal array: graph.facebook.com/576234822476425/likes.
First post - post from user, second post - post from page.
How do I get a normal result in the first case?
http://graph.facebook.com/773227196065108 returns
{
error: {
message: "An access token is required to request this resource.",
type: "OAuthException",
code: 104
}
}
since its a user post and probably not public, you will have to access it using a proper access token on behalf of the user . also the number of likes obtained via graph api is dependant on the the privacy settings of people who liked the post .
the second post is one from a page and is public, so its directly accessible for you .
773227196065108 is a user whereas 576234822476425 is a page. Public page posts can be inspected in the API, public user posts have certain restrictions applied to them such as, the queried user must be using the application as well. If the queried user isn't using the querying application the response will be empty.
In addition /me/likes/773227196065108 will not work as /me/likes are only for pages not posts.

Facebook realtime updates for page contain invalid post id

I've set up a subscription so that my app receives realtime updates for a specific page. This works as expected, and I'm receiving updates when a user posts to the page.
The update only contains the page id, so I then use the Graph API to get the details of the post. The problem is that the post id in the realtime update isn't valid and I get an error from Graph API.
If I query the page's feed, the post shows up there with a different (correct) id.
The correct id consists of <page id>_<post id>. The one in the realtime update is just the <post id> without the prefixed page id.
The data in the realtime update:
{
"object":"page",
"entry":[{
"id":"<page id>",
"time":1372177485,
"changes":[{
"field":"feed",
"value": {"item":"post", "verb":"add", "post_id":<post id>}
}]
}]
}
The Graph query:
http://graph.facebook.com/<post id>
Response:
(GraphMethodException - #100) Unsupported get request.
The Graph query is being performed using a long-lived (non-expiring) page token. I get the same response using the Graph API Explorer tool (https://developers.facebook.com/tools/explorer) and also when using a short-lived user token.
Obviously I could simply prepend the page id onto the given page id to generate a valid id, but that's not very robust, should the format change at any time. Why isn't Facebook returning valid ids? Is there something I'm doing wrong?

Retrieving facebook user wall posts through graph API

I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
{
"data": [
]
}
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException"
}
}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
According to the latest api ,
FB.api("/me/feed","get",function(response) {//callback})
should do and also work well .
It is working now but facebook may change it in future.