Facebook api get post of specific user - facebook-graph-api

Im trying to inquire an open and public group by using the graph API
https://graph.facebook.com/396697410351933/feed?{TOKEN}
So far so good and i'm receiving a json with the latest posts
is there any way to get only specific user post by using the from.id value
"from": {
"id": "123456",
"name": "XXXX"
},
somthing like that
https://graph.facebook.com/396697410351933/feed?{TOKEN}&id=123456
thanks,
miki

There's currently no way to filter this via the Graph API. If you have access to a Graph API v2.0 app, you could use FQL to filter as you desire. Be aware that FQL will be deprecated in August 2016.
See
https://developers.facebook.com/docs/reference/fql/stream/
Try actor_id as the ID of the person which posted the post, and source_id as the group id.
Sample query:
select actor_id, message, created_time from stream where source_id=396697410351933 and actor_id=10152352765098713

Related

How to post a photo to a page with a tagged Product via Graph API v12.0?

We have a Facebook Shop and a Business Page, and are using Facebook Graph API to create Photo posts on the Business Page using the Javascript SDK running in a browser. How do you include the tagged Product in the Create Photo request?
https://developers.facebook.com/docs/graph-api/reference/photo/ mentions a tags field you can pass which is described as "Tags on this photo", however it has a tag_uid "The user_id of the tagged person". Is this tags field how you are supposed to tag a product?
A similar question from 2017 was not answered and is so old I thought I'd post a new one: Publish new facebook post with tagged product
What we've tried so far
To get a list of our products, we can use GET ${businessId}/owned_product_catalogs to retrieve a list of catalogs, and then GET ${productCatId/products with a filter: '{"custom_label_0":{"eq":"something_to_match"}}' to get a specific product in the catalog. So now we have the ID of a product we want to tag e.g. "4378279312278116". (we happen to use custom_label_x fields meaningfully, of course the filter could have been something else but this works for us)
To create the photo post, we can POST /${account.id}/photos with a payload like:
{ caption: 'Test caption',
url: image_url,
access_token: account.access_token,
tags: [
{
tag_uid: "4378279312278116",
tag_text: 'Test tag',
x: 10, y: 10
}
]
}
This request completes OK and does post the photo, but nothing is tagged on it when we view it on our page.
Trying to read the photo with GET ${photo_id} only returns basic infomation fields created_time, id, name. I can't see how to read further fields on the photo object to check if the tags data was associated with it correctly.
Any advice please?

Facebook Graph API feed not working

I'm completely new to Facebook Graph API.
I'm trying to use the Graph API Explorer: https://developers.facebook.com/tools/explorer/
I got the token, I'm using GET method and version 2.5 of FQL, and following is the query itself:
me?fields=id,name,picture,feed
The result from that query unfortunately only includes the id, name and picture but does not include the posts. I also tried to write "posts" instead of "feed", but the result was the same.
This is what I get:
{
"id": "123456789",
"name": "John Smith",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/very-long-url"
}
}
}
As you can see, nothing about the posts.
I also tried to open a new Chrome tab and go directly to this URL:
https://graph.facebook.com/me/feed?access_token=very-long-token
And this is what I get for that:
{
"data": [
]
}
What am I doing wrong?
Any help will be profoundly appreciated!
Did you try with user_posts permission?
Maybe you forgot this...
https://developers.facebook.com/docs/graph-api/reference/v2.6/user/feed
Your app needs user_posts permission from the person who created the
post or the person tagged in the post. Then your app can read:
Timeline posts from the person who gave you the permission. The posts
that other people made on that person Timeline. The posts that other
people have tagged that person in.
Cheers

facebook graph API company page URL?

I am working on some data analysis regarding beverage manufacturers in the US and would like to grab posts from the company facebook pages to mine some data using the standard facebook graph API. I am new to the facebook API and I am hoping to get some clarifications here that I can't find in the developer docs.
For a simple example lets look at 2 companies FB pages:
https://www.facebook.com/CocaColaUnitedStates
https://www.facebook.com/BellsBreweryInc
Now per the API documentation, I should be able to retrieve the posts on those public company pages via a URL as follows:
https://graph.facebook.com/COMPANYFBNAMEHERE/feed?access_token=MYTOKEN
or
https://graph.facebook.com/v2.5/COMPANYFBNAMEHERE/feed?access_token=MYTOKEN
This works for CocaCola: https://graph.facebook.com/v2.5/CocaColaUnitedStates/feed?access_token=MYTOKEN
This returns data as I would expect:
{
"data": [
{
"message": "The French \"yes! yes! yes!\" sounds like \"we! we! we!\" (lettered \"oui.\") \"C'est la vie\" sounds like (homonym) \"say LOVIE\" (like lovie dovie).\n\nSong of (rather than \"by\") Robbie Nevil: C'est La Vie\nhttp://www.youtube.com/watch?v=CGtf9QfITQw",
"created_time": "2016-02-06T02:52:17+0000",
"id": "820882001277849_452698638250376"
},
etc....
However when I try this for Bell's: https://graph.facebook.com/v2.5/BellsBreweryInc/feed?access_token=MYTOKEN
I get this:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "AWTxWye6vub"
}
}
I am not understanding why I am getting an error on Bell's page? It's a publicly available company FB page, so I can't imagine it's a restriction, but I can't understand why it wouldn't be returning the posts like CocaCola?
It sounds like the owner of the token you are using is below the legal drinking age. BellsBreweryInc is a page in the alcohol category so no data will be returned for users under the legal age. This is something BellsBreweryInc would have set in their page settings.
Age restircted websites require a user access token from a user account that meets the page requirements. I was using an app access token which is why it didn't work.
I needed to log into my account and generate a user access token and use that token in the URL.
Also, just realized that token expires in a couple hours. Anyone wanting to do this may also want to read this: How to extend facebook access token in python

How to scrape user's facebook feed using Graph API?

I'd like to scrape some user's posts from Facebook. Posts are visible in browser, when I'm logged in and I am looking at http://fb.com/username URL. But when I'm trying to access the same feed using Graph API Explorer (https://graph.facebook.com/v2.3/username/feed) I'm getting:
"error": {
"message": "(#803) Cannot query users by their username (username)",
"type": "OAuthException",
"code": 803
}
If I try to use id instead of username (http://graph.facebook.com/v2.3/userid/feed) I'm getting empty JSON in response:
{
"data": [
]
}
So, is there a way to get the user's feed using Graph API? Or do I have to imitate a web browser and parse HTML then?
You are not supposed to grab the feed of any user, public or not. You need to authorize a user with user_posts to get access to his feed - and his feed only.
Also, usernames are not available in the Graph API anymore, you need to use an App Scoped ID now. You get that when you authorize the user.
Btw, scraping is not allowed at all: https://www.facebook.com/apps/site_scraping_tos_terms.php

How to use Facebook graph API query correctly

i am a new comer .Someone suggested me that i will get a solution of my question from this site.So that's why i am posting my question in here.
When i used this facebook fql query:
http://graph.facebook.com/fql?q=SELECT+like_info+FROM+photo+WHERE+object_id=723217944369470
Answer was:
{
"data": [
{
"like_info": {
"can_like": false,
"like_count": 7,
"user_likes": false
}
}
]
}
But when i used this facebook fql query:
http://graph.facebook.com/fql?q=SELECT+like_info+FROM+stream+WHERE+post_id=488253731301614
Answer was:
{
"data": [
]
}
Why?and how to query correctly to get a post's like info?
In graph API, you can do something like this to get a post's likes:
https://graph.facebook.com/POST_ID/likes?access_token=ACCESS_TOKEN
You need to replace POST_ID and ACCESS_TOKEN with actual values.
You can use Graph API Explorer to generate an access_token
https://developers.facebook.com/tools/explorer/ (don' forgot asking for sufficient permission to view the post in question).