When I use postman application or Graph API explorer then i get complete information or all fields of posts as explained in https://developers.facebook.com/docs/graph-api/reference/v2.0/post
I have not use fields attribute in above image even then it is showing all fields so i am looking for the answer to pass field attribute in query string.
But when i use SDK i get only 3 fields created_time, id and message, please refer following image:
Kindly tell how to get all fields of the posts using facebook sdk c#?
You need to specify the fields parameter, it´s called "Declarative Fields" and came with v2.4 of the Graph API: /me/posts?fields=field1,field2,field3,...
The possible fields can be found in the docs, you should use the latest version though: https://developers.facebook.com/docs/graph-api/reference/v2.7/post
Make sure you are using a newer Version of the API, you are trying to use v1.0 in Postman (which does not exist anymore).
Related
I created an app in Facebook a while back to get a feed from a specific clients page. The feed looks something like so:
I am trying to do the same with a new client and now the feed looks very different:
What am I doing wrong? Is there something I can do to get the old feed style back, because it gives so much more information than the new API versions feed.
The older app is version 2.0 and the newer one is 2.5.
What you missed is that with all Graph API request above v2.3, you need to specify the fields you want to have returned from the Graph API. Otherwise only a small standard set of fields is returned.
See
https://developers.facebook.com/docs/apps/changelog#v2_4
Declarative Fields
To try to improve performance on mobile networks, Nodes and Edges in v2.4 requires that you explicitly request the field(s) you need for your GET requests. For example, GET /v2.4/me/feed no longer includes likes and comments by default, but GET /v2.4/me/feed?fields=comments,likes will return the data. For more details see the docs on how to request specific fields.
related to Open Graph api for feed returning inconsistent results
When I publish a post on a page's feed using my App, facebook returns some id in the form of <page_id>_<post_id>, but when the same App receives a Real time Update from the same page—say a like or a comment—the parent_id field of the like or comment contains only the <post_id> part!
Is this a bug or what?
Here is the response from facebook engineers -
This is by design. For a realtime update generated by a comment, the parent_id will just show and not include the page_id.
For specific examples, please refer to our documentation (https://developers.facebook.com/docs/reference/api/page/#realtime) and look under the sub-sections "Feed Example."
I'm struggling in getting the posts from the public page in Facebook. For example
https://graph.facebook.com/cocacola
(Its a public page, those who liked it on facebook will get update.)
This returns me the page details only. How I can get the wall posts done by the user "cocacola".
Its quite simple. just do as
https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed
It will work.
I'm a bit late at the party but for completeness I would like to add:
Using the latest version 2.2 you can access the feed via the page id, eg:
https://graph.facebook.com/v2.2/PAGE_ID/feed?access_tkoen=YOUR_ACCESS_TOKEN
Individual posts can be retrieved too by their own id or via the feed.
https://graph.facebook.com/v2.2/POST_ID?access_token=YOUR_ACCESS_TOKEN
Maybe this was also possible with the older versions? Don't know, I'm just getting started.
Is it possible to get and to change the new porfile cover (mine or my friends' profil cover) with the sdk php or JS ?
It is possible to get the Facebook's user cover image using the Graph API. You have to add 'fields=cover' to the user request. The response is an array of fields id, source, and offset_y. You need an access token for this.
You cannot update the cover photo using the API, only retrieve it.
http://graph.facebook.com/[USER_ID]?fields=cover
It's still not possible with the current APIs exposed by Facebook.
I want to access graph API to get the number of shares for different pages of my website. I can use the GET method to do so but I want to use POST so that I can send more url in a single request. The current implementation I have for GET is
http://graph.facebook.com/?ids=http://umairj.com/,http://umairj.com/146/how-to-clear-facebook-shares-cache/
Can anyone please help ?
This is badly documented (I mean I didn't find the information when I looked for it!), but there is way to pass all the parameters to the Graph API through POST method:
in your example, you should POST to http://graph.facebook.com/
with the following DATA:
ids=http://umairj.com/,http://umairj.com/146/how-to-clear-facebook-shares-cache/&method=GET
I'm not sure about the encoding of the POST DATA..in our case, we were just using ids=.....,.....,..... with numeric FB user ids and we didn't need to do any encoding, but you might need some url-encoding
Don't forget the &method=GET or it won't work ! It helped me break the url length limit that was causing bugs on Internet Explorer (I think RFC says 1024 characters, all browsers support much more, IE only ~4096 ) when we were passing too many ids through GET
if you wish to access non-public information, the same trick works with https://graph.facebook.com/ , provided you add &session_token=***** to your query
You can try to run a FQL query to get the stats for multiple urls. Facebook link_stat documentation has an example of how to do this. I'm pretty sure you can't POST to either the FQL query or the graph api you were using though unfortunately. Your FQL query would be:
SELECT url, share_count, like_count FROM link_stat WHERE url IN("http://umairj.com/","http://umairj.com/146/how-to-clear-facebook-shares-cache/")
Here is the url after properly url encoding the query: https://api.facebook.com/method/fql.query?query=SELECT+url%2C+share_count%2C+like_count+FROM+link_stat+WHERE+url+IN%28"http%3A%2F%2Fumairj.com%2F"%2C"http%3A%2F%2Fumairj.com%2F146%2Fhow-to-clear-facebook-shares-cache%2F"%29&format=json
Facebook provides a FQL testing tool to help.
Update: their API documention (see section titled "Delete) mentions you can do an HTTP POST to any of their methods and set the variable method to the method you want. You could try this, although this was designed for delete and put methods not available to javascript clients. It still looks like is all url based so I'm not sure it will take a form encoded parameter like you are looking to do.
I work at Facebook and I've updated our Graph API documentation to document this work around for very large requests:
https://developers.facebook.com/docs/graph-api/using-graph-api#largerequests