I'm experiencing some problems getting an Open Graph implementation working.
As far as I can tell, I have the correct meta tags present. When I paste an URL into the Open Graph Debugger, it returns with the proper information defined (title, description, image, etc), and no errors.
I have version 3.1.1 of the Facebook PHP SDK.
I have Open Graph enabled for my development app, and I have an action (read), and an object (article) defined.
The implementation in question is a website, not a facebook application. On facebook, the app's "category" is "other". I followed some advice in another thread, and changed it to "Game", which did not work, so I have changed it back.
I authenticate my web app user with facebook and receive a code, which I then trade in for an access_token, pretty standard. I ask for the following permissions:
publish_stream
publish_actions
offline_access
However, when I attempt to make a call to publish an action, I receive an OAuthException, and have no real way of debugging it.
Some oddities:
The graph API doesn't seem to like the URL format specified in the documentation: me/[app_namespace]:[action_type]. In my case, this would be me/' . FB_APP_NAMESPACE . ':read, where FB_APP_NAMESPACE is defined earlier to be a namespace as defined in the facebook application settings. Both the API and the Graph API Explorer throw an error stating that it doesn't understand the action given. It seems to be trying to read the namespace as the action.
If I remove the namespace from the url, it reports that the passed in action doesn't match the og:type defined in the url, since the og:type in the url contains the same namespace I removed.
If I remove that namespace from the meta tag, and try again, I get a generic OAuthException that I can't debug.
When I look at the code sample provided in my facebook app, the action seems to be news.reads instead of just read.
If I use that action, the graph API returns an error saying that my ID is unauthorized to use the open graph, as it is not an admin, dev, or tester for my application. Unfortunately, I am the app creator, which means either the graph API is lying, or I am lying to myself!
I think the solution is pretty simple - perhaps I have forgotten something, or selected a certain category incorrect. Either way, this is a little frustrating, to say the least!
Apparently, facebook's default read call isn't available to use if your application/action isn't submitted.
I ended up creating my own read action, and it worked on the first try. Go figure.
For predefined actions the post url's are slightly different, you will have to use something like this:
POST https://graph.facebook.com/me/news.reads?article=[article object URL]
See: https://developers.facebook.com/docs/opengraph/actions/builtin/#read
Related
I want to fetch metadata of any web-page using Facebook Open Graph Object Debugger.
We can get it from this URL: Open Graph Object Debugger
Example: Open Graph Object Debugger for Google
It will provide all the information related to that URL. Is there any way to get this information using API(in JSON format)?
Yes, via the API URL Object described here and in even more detail here. Note that you can issue a POST request to this URL to force a refresh. You can even get additional data such as how many times that link was shared on Facebook!
https://graph.facebook.com/v2.10/?fields=og_object&id=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2015381%2F&access_token={YOUR_TOKEN}
I did experience inconsistencies, namely if the obejct does not exist the API will return nothing but if you query it a few seconds later it will be there. For this reason we could not rely on Facebook and simply fetched the page ourselves and parsed out the og:* tags.
It may be perfect if you don't care about misses and having to re-fetch or if you just want to programmatically clear the Facebook OG cache.
It's wise to post to it every time you create a new page to force the cache or sometimes the first person to paste the URL into Facebook won't get the link preview!
Yes you can use this https://urlmeta.org
Its usage is pretty simple. Just make a GET call and pass the URL to API endpoint: https://api.urlmeta.org and you are done.
I want to list Facebook Page Post in a application. Therefor I use the Facebook Graph API.
I use the following URL:
https://graph.facebook.com/v2.9/674600022698736/feed?limit=100&fields=name,comments.limit(0).summary(true),permalink_url,shares.limit(0).summary(true)&access_token=XXX
I get the response, except for the fields': icon and shares. In the feature I need more, so maybe the problem is with more fields.
De Graph Explorer gives the following response for the fields icon and shared: "Field is empty or disallowed by the access token".
The shares are certainly filled!
See:
I've made the call with both the user and the page tokens, same result.
How can I solve this problem?
Although this post is old but has no answer, my answer might help someone:
If those edges are greyed out, it means you did not give or add those attributes in the access token your calling with. You need to give those permissions.
After adding such permissions for example for your case: like, comments you need to regenerate the token by clicking on the Get Access Token button and you should see it not grey anymore. Finally, you can Submit and get your desired response.
Classic Graph Explorer
1.
2
3.
Better yet, try the new beta Graph Explorer. Has a better GUI for the permissions option.
Beta Graph Explorer
The following public post which is visible on the page it was posted (it is not "hidden") is a mystery to me: https://www.facebook.com/Orange.France/posts/833781953305851
i.e., it is not available in the page's /feed edge, and the graph API can't retrieve it either. The following command returns an "unsupported get request":
curl https://graph.facebook.com/170852259598827_833781953305851?access_token=XXX
I tried also the following without much success:
curl https://graph.facebook.com/833781953305851?access_token=XXX
In both cases, I tried the access_token of the page as well a random access_token generated from the graph explorer.
So, the question is: how can I retrieve this post through the FB API ?
You can't retrieve that post via the API - it was made by a user whose data cannot be accessed via the API by any app due to their privacy settings
You can see this by trying to load the poster's details (https://graph.facebook.com/<username>- it fails with the same exception)
Such posts will never be accessible via the API, because the person who made the post has explicitly disabled all apps from interacting with them or their posted content
If you want to prevent such users from posting on the page, there's an API-settable option called which will stop this - documentation for how to apply settings to the pages your app manages is here: https://developers.facebook.com/docs/graph-api/reference/page/settings
The specific option you need to enable to prevent platform-opt-out users from posting is called PLATFORM_OPTOUTS_CAN_POST
The main reason is not because of page, but it's because of the author turn the platform off.
You can't query the author basic info via Graph API.
The author can turn the platform off, so any Graph API query including comments wouldn't include him.
This is a series of questions about implementation with the Facebook open graph.
So, I make a query to the api as such: $this->facebook->api('me/namespace:action', 'post', $args );
My first query is where do posts appear? For example if I make a call with the parameters as follows:
$args = array(
//'message' => 'I just posted a pub review at PubJudge.com',
'website'=>'www.pubjudge.com',
'user'=>current_url(),
'link' => 'http://www.pubjudge.com/',
'caption' => 'Independent, social, pub reviews.'
);
The post appears on my timeline under 'Activity'
As far as I understand, if a user explicitly shares an action it will appear on the timeline. Is this correct?
Is "fb:explicitly_shared" a parameter that should be passed in the $args array?
Next comes Facebooks custom meta data. In this case my obect is a user, and I pass their URL through the $args array. Facebook then scrapes this array to get data from the custom meta tags on this link. Is this correct?
Does this url have to be the url from which the action is initiated? Can I not have a page on my website which simply generates custom meta tags based on a $_GET variable - this way I can keep all this complicated Facebook stuff independent of the main site.
Does anyone know why Facebook gets data for open graph actions like this anyway?
Finally because Facebook scrapes data like this I cannot test this functionality on my localhost. (I could do but it'd be very complex) What I have opted for instead is a testing.domain.com address to test my website and this functionality whilst having domain.com as my main live stable site.
I have also created two apps.. my main app, and a testing app because if I use my main app I have to change the site url to testing.domain.com which then breaks my stable site. Is this a suitable approach?
As far as I understand, if a user explicitly shares an action it will
appear on the timeline. Is this correct?
Yes, that's correct. You can find more information at the Facebook docs for explicit sharing. To be noted from the docs, you'll have to mark your action as able to explicitly share on your app dashboard and Facebook will have to approve it.
Is "fb:explicitly_shared" a parameter that should be passed in the
$args array?
Yes.
Next comes Facebooks custom meta data. In this case my obect is a
user, and I pass their URL through the $args array. Facebook then
scrapes this array to get data from the custom meta tags on this link.
Is this correct?
Yes, Facebook scrapes the URL you pass so they can get data from the OG tags at that link.
Does this url have to be the url from which the action is initiated?
Can I not have a page on my website which simply generates custom meta
tags based on a $_GET variable - this way I can keep all this
complicated Facebook stuff independent of the main site.
No, it does not have to be the url from which the action is generated. You can have a separate page on your website, and in fact you can even use javascript to redirect users who land on that page to a more appropriate page.
Does anyone know why Facebook gets data for open graph actions like
this anyway?
That's probably a deeper question than you realize. In short, they are trying to create a semantic web. The long answer would be an essay.
Finally because Facebook scrapes data like this I cannot test this
functionality on my localhost.
You can use reverse proxy which works in most cases (I've seen problems with photos if you are using a port for the reverse proxy). Not very complicated. Something like the following works well:
ssh -nN -f -R externalhost.com:49080:localhost:80 your#credentials.biz
I have also created two apps.. my main app, and a testing app because
if I use my main app I have to change the site url to
testing.domain.com which then breaks my stable site. Is this a
suitable approach?
Yes, that's normal. We typically have a development app (localhost), a staging app (external host for testing), and a production app.
I try to fetch user's feeds via graph api from my Android application. It generally works but some feeds that I can see on the wall are missing in the json response.
I call the url http://graph.facebook.com/someUserId/feed, by using the Android Facebook SDK methods, so the access token should be provided automatically, but it's not really relevant I think in my case. Nevertheless fyi, the user of my app is authenticated via OAuth.
I already checked the following:
all the user's feeds are visible to everyone / public (set in privacy settings)
the json response is not cached by my browser
I am aware of paging, but this is not an issue. The problem is not that I am not getting the very oldest feeds but that some feeds are just missing in between.
I registered a new facebook user which is not connected to the user I want to retrieve the wall feeds from, and when I open the respective wall I see all the feeds there, as expected, since they're all public to everyone. Yet, when I open the same related json url unter http://graph.facebook.com/someUserId/feed, some feeds are missing.
This is an example of the problem - since all my posts are public, I can just call the json url directly in a browser to do a test.
I want to get wall feeds from user:
http://www.facebook.com/mathias.lin
Screenshot1: note the 3 marked postings, all posted by myself
and here the json response, as you can see, the 1st and 3rd wall posts are included in the json, but the 2nd post is not. Why?
The related json url is:
http://graph.facebook.com/mathias.lin/feed
I am getting the 'missing' feed when I add an access_token to the url - but why? The posted feed has a privacy setting for 'everyone'?!
This is the missing feed that I get when using the access_token:
{"id":"504063796_485195138796","from":{"name":"Mathias Lin","id":"504063796"},"message":"Photo test upload from Android","picture":"http:\/\/photos-e.ak.fbcdn.net\/hphotos-ak-snc6\/hs021.snc6\/165194_485195123796_504063796_6062399_1841907_s.jpg","link":"http:\/\/www.facebook.com\/photo.php?fbid=485195123796&set=a.485195118796.256450.504063796","name":"Torres Photos","icon":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/yz\/r\/StEh3RhPvjk.gif","actions":[{"name":"Comment","link":"http:\/\/www.facebook.com\/504063796\/posts\/485195138796"},{"name":"Like","link":"http:\/\/www.facebook.com\/504063796\/posts\/485195138796"}],"privacy":{"description":"Everyone","value":"EVERYONE"},"type":"photo","created_time":"2011-01-06T05:10:43+0000","updated_time":"2011-01-06T09:00:23+0000","likes":6,"comments":{"data":[{"id":"504063796_485195138796_3607414","from":{"name":"Mathias Lin","id":"504063796"},"message":"Awesome, photo upload now works as well. Not so much fun working with the Facebook SDK for Android, would have expected more functionality beyond that just very very simple graph api wrapper. But need to be considered that the android sdk development was part of an internship - but since it's it's open source, it can luckily be modified. Which has to be done due to some bugs (mixing up the bundle parameters for a post, getString, getByteArray). Api documentation could be improved.","created_time":"2011-01-06T05:26:04+0000"},{"id":"504063796_485195138796_3608020","from":{"name":"Renate Hermanns","id":"628810487"},"message":"Wow
, how fast time passes by. Your daughter is nearly grown up ;-).","created_time":"2011-01-06T09:00:23+0000"}],"count":2},"attribution":"Torres"}
I've already posted the question to the FB dev forum, awaiting response.
Related threads:
http://forum.developers.facebook.net/viewtopic.php?id=81365
http://forum.developers.facebook.net/viewtopic.php?id=75984
Facebook Graph API "/userid/feed" returning Blank
Your approach is correct, I've seen the JSON and yes it's missing the second one, I think it's upload app form adroid, try checking the application settings for this app. Or If your trying to retrieve the wall FQL is a much better way
SELECT post_id, actor_id, target_id, message FROM stream WHERE source_id in (SELECT target_id FROM connection WHERE source_id=<uid> AND is_following=1) AND is_hidden = 0
I've been through this, the way Facebook is categorizing their permissions is somehow misleading, for example Publicly available may sounds like Available to everyone on Facebook but apperantly it's not.
Now in your case, if you already authenticated the user, then try using:
/me/feed
I guess this is the only case where access_token is not needed in the URL.
I had a similar problem. But for me, the problem was related to not setting the scope properly on first login (to authorize the app). I posted a similar question and got an answer that worked for me here:
Facebook API how to get all wall items