Facebook Graph API URL Scrape Inconsistent - facebook

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.

Related

Viewing graph api via url not showing data

So I have been watching some tutorials about the facebook graph API, and one of the things in the video is to simply navigate to http://graph.facebook.com/youtube
and it should display a json response of their facebook likes etc. This is said to work without an access token?
But this doesn't seem to work, i get the following response -
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104,
"fbtrace_id": "DoY144sSuti"
}
}
Has something changed that you will need to always need an access token just to see peoples data, eg how many likes a page has?
Has something changed that you will need to always need an access token just to see peoples data, eg how many likes a page has?
Yes. Since API v2.0, all API calls (with the profile picture redirect being the exception) need to use an access token.
Public data about public pages can be accessed using an app access token; if the page is not public it needs a user access token for a user that can see the page, or a page access token. (More about the different types of token here: https://developers.facebook.com/docs/facebook-login/access-tokens)
This is said to work without an access token?
Then that tutorial is simply outdated.
Yes you will need the access token in order to view that Jason data in URL .
try this Instead :
https://graph.facebook.com/page-id/posts?access_token={your-access- token}
You will be able to see the posts now.Hope this would help you .

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 JS SDK throwing 104 error when attempting to delete a app request

I have setup the facebook javascript sdk to initialize a friend invite dialog to send requests to friends. Clicking on the invite in Facebook, brings the user back to the site.
The query string has any and all request_ids that have not been handled (deleted).
I am following the documenation listed at the FB developers site here which states:
JavaScript SDK:
FB.api(requestId, 'delete', function(response) {
When they are returned to my site, the querystring has a request_ids parameter:
example: www.mysite.com/somepage?request_ids=0493834050
my Javascript code looks like this:
FB.api(requestIds[i], 'delete', function (response) {
console.log(response);
});
But the error I get is:
ERROR
code: 104
message: "An access token is required to request this resource."
type: "OAuthException"
All I want to do is delete the request ID. before I was even running the above code, the querystring was building up with every submitted request. It does appear they have been removed, because the querystring is reduced down to a single request id. But I am still uncertain it has been handled properly.
NOTE I am not using the Graph version - as I have not setup Graph on the app settings in Facebook.
I have the Facebook C# sdk - if someone has an easy way to do this here. I have tried the following with the same results.
var fbClient = new FacebookClient(accessToken)
fbClient.Delete(requestId);
I don’t see what’s possibly unclear about the error message – you need a valid access token to be able to delete requests, but by the looks of it you don’t have one.
So you’ll either have to have the user connect to your app in order to get an active access token for him; or you have to do it using your own app access token (but that’d have to be done server-side then, because you don’t want to transfer your app access token to the client side).

Bad Request/Method not Implemented Error when Publishing Actions to the Timeline

I am working on a Joomla site and using myApi to handle most facebook integrations. The like button is working fine and picking up information from the og meta tags inserted by myApi.
On the website, the user can login using facebook - I have added the publish_actions permission to the myApi code, and I know this is being requested because when authorising the app, the oauth dialog says that actions like ordering from restaurants (the action i added to my fb app) will be posted to the timeline.
now, while ordering, I check whether the user has an entry in the myApi user table and if so, I provide a checkbox that lets the customer choose whether she wants the order action posted to her timeline. if ticked, I then use curl to try and post the order action to facebook. I have been using my account to test - I have authorised the app with all permissions requested. I use the myApi interface to get my user access token. I am adding the access_token and object url to the url as querystring parameters and then posting to it through curl.
The curl response I get is:
<HTML><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Method Not Implemented</H1>
Invalid method in request<P>
</BODY></HTML>
the response I get when going to the generated url in my browser is
{
"data": [
],
"paging":{
"next": "https://graph.facebook.com/me/og_collegekhana:order_from?restaurant=http\u00253A\u00252F\u00252Fwww.collegekhana.com\u00252Fstates\u00252Ftamil-nadu\u00252Fcampus-1\u00252Feat-1&access_token=[the token I got]&offset=25&limit=25"
}
}
I checked the object id of the url using
https://graph.facebook.com/?ids=http://www.collegekhana.com/states/tamil-nadu/campus-1/eat-1
I am not getting an object id. instead I get
{
"http://www.collegekhana.com/states/tamil-nadu/campus-1/eat-1": {
"id": "http://www.collegekhana.com/states/tamil-nadu/campus-1/eat-1"
}
}
I am completely lost and hope someone can tell me what I am doing wrong.
The problem was that instead of doing a cURL POST, one has to add the querystring parameter
method=post to the URL.

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.