I have a requirement to read latest facebook inbox comments using created Date.
Please let me know the URL for getting latest facebook comments using created date.
Thanks,
I manage to get Inbox comments (messages) by using FQL query.
Try calling,
FB.api({
method: 'fql.query',
query: 'SELECT thread_id, body, author_id, created_time FROM message WHERE thread_id = 1327060333367 and created_time=1277394689'
}, function ( inboxresponse ) {
//do stuff here with results
});
Please note that you need to pass the thread_id and created_time ( in unix timestamp ) and also have "read_mailbox" permission.
Please let me know about this !
Related
Facebook mentioned they're now making reels data available with the /insights endpoint, yay (see here )!
Although the article says they've updated their docs I don't see how it would be formatted, do we think the format will be like this?
insta_page_id/insights?metric=reels&period=lifetime
For a reels post in Instagram, you can try the following query in the Meta Graph API explorer(Assuming you have an app with required permissions):
[IGpost-id]/insights?metric=likes, comments, shares, plays,reach,saved,total_interactions
The above query should give you a response for these metric.
Currently I did not find any media_type as "reels". A reels media_type is still tagged as Video. Only way to identify if a post is a reel is through the permalink url which contains https://www.instagram.com/**reel**/XXXXXXX in it.
https://developers.facebook.com/docs/instagram-api/reference/ig-media/insights/
Thanks to #KristiLuna's comment above I was able to solve a similar problem.
Instagram reels are still identified by the Instagram Graph API as media_type: "VIDEO". The way to tell the difference between a feed video and a reel is by checking the media_product_type field on the Graph API.
My approach (to loop through an Instagram user's media):
fetch (`https://graph.facebook.com/v14.0/${ig-user-id}/media?fields=id,media_type,media_product_type`, {method: 'get'})
.then(response => response.json())
.then(data => {
let dataObject = data.data
dataObject.forEach((item, i) => {
if (dataObject[i].media_type === "VIDEO" && dataObject[i].media_product_type === "REELS") {
// do stuff
})
}
}
Is there a way to add user-data (a number or a string) and use it while querying posts from the stream of that page ?
Essentially I am trying to make posts with certain attributes on a Facebook page thru an App and would like to query the stream (newsfeed) on that page using FQL or Graph API and just select the specific posts based on the attributes added to the posts.
SELECT post_id FROM stream WHERE **user_data** ='tag-specified-with-post' app_id='APP_ID'.
Thanks for your help.
Use FQL to get posts from your app. This query will get posts made in the account of the user by the Photos app:
SELECT app_id, post_id, actor_id, target_id, message FROM stream WHERE filter_key ='owner' AND is_hidden = 0 AND app_id='YOUR_APP_ID'
Replace that app_id with yours. And replace filter_key with 'others' to get other people's posts that the user can view.
I am creating a simple CMS system whereby users can contribute inspirational posts made by brand pages on Facebook. All the user has to do is paste in a permalink to a post and the CMS will handle pinging the Graph API in order to acquire all the info it needs. (e.g. https://www.facebook.com/photo.php?fbid=10152047553868306&set=a.99394368305.88399.40796308305&type=1&relevant_count=1)
One of the requirements of the CMS is that like, comment, and share counts are included for each post. This is where I struggle.
Simply pinging the graph endpoint with a photo ID will only return a paginated list of likes/comments. There is no parameter for total likes or total comments. Fortunately, the photo table includes like_info and comment_info members for me to query upon. This works great for getting totals on photos:
SELECT like_info, comment_info FROM photo WHERE object_id = 10152047553868306
One would expect then that I could apply the same FQL SELECT on the status or video tables in order to get the like and comment info for status updates and video posts but you cannot. like_info and comment_info only reside on the photo table.
At least right now I can get like/comment total for photos, but I still see no indication on how to get share totals for a photo.
Is there a way I can reliably acquire like, comment, and share counts for video posts, photo posts, and status posts? Using any combination of Graph or FQL API?
Any help would be extremely appreciated.
I have found something like this for facebook graph api v2.8
$accessToken ="XXXXXXXXXX";
$fb = new Facebook\Facebook(array(
'app_id' => 'Facbook App Id',
'app_secret' => 'Facebook Secret Key',
'default_graph_version' => 'v2.8',
));
$params = array();
$request = $fb->request('GET', '/{post_id}/?fields=likes.limit(0).summary(true),comments.limit(0).summary(true)',$params,$accessToken);
$response = $fb->getClient()->sendRequest($request);
$graphNode = $response->getGraphNode();
$likeArr = $graphNode['likes']->getMetaData();
$commentArr = $graphNode['comments']->getMetaData();
echo "Total Post Likes : ".$likeArr['summary']['total_count'];
echo "Total Post Comments : ".$commentArr['summary']['total_count'];
use this:
SELECT user_id FROM like WHERE object_id=10151751324059927 LIMIT 1000
Hey all,
I've made a facebook application for a contest, which allows users to upload their photo. Once uploaded, the photo gets posted to a dedicated album on their profile. Once the photo is there, the users should collect as many likes as possible.
Currently i have tried both the Facebook Graph API and Facebook FQL to retrieve the amount of likes, but the retrieved likes don't always match the likes on a users profile.
Some users claim to have more then 200 likes, yet the API only returned a maximum of 101 likes so far.
All users are requested to grant the application the following permissions:
user_hometown, publish_stream, read_stream, user_photos and offline_access
Using Facebook PHP SDK 3.0.1 I tried this FQL query to collect the amount of likes of a photo:
# fql query
$fql = "SELECT object_id FROM like WHERE object_id=" . $photo_id;
# api request
$request = array(
'method' => 'fql.query', 'query' => $fql
);
# run batch request
$likes = $this->facebook->api($request);
# return like count
return count($likes);
I also tried the following Graph API request (Also with Facebook PHP SDK 3.0.1) to collect the amount of likes of a photo:
$likes = $this->facebook->api($photo_id.'/likes');
return count($likes['data']);
Strangely, neither seem to return correct results. I can understand if the API is slightly inaccurate, but according to the API some pictures recieved 100 likes this morning and then 0 likes a few hours later.
Does anyone have any ideas what i might be doing wrong? Do the photo's and their albums need to be public? Do the people who liked the photo need to have a public profile in order to show up in the API? Do i need to request additional permissions?
Any help or suggestions will be greatly appreciated!
Just had the same problem here. The likes seems to be paginated by hundreds by default. Override this setting by using the "LIMIT" query option.
Does anyone have any ideas what i might be doing wrong?
yes, I believe that it is against Facebook policy to use their likes plugin for a contest. See: https://www.facebook.com/promotions_guidelines.php
# fql query
$fql = "SELECT like_info FROM photo WHERE object_id=" . $photo_id;
# api request
$request = array(
'method' => 'fql.query', 'query' => $fql
);
# run batch request
$likeInfo = $facebook->api(array(
'method' => 'fql.query', 'query' => $fql
));
var_dump($likeInfo);die;
=> get like info of photo
brand new here.. I've looked everywhere, couldn't find an answer.. :/ Hopefully someone here can help me out. I'm using the graph api to upload a photo, and tag the user in it. This is currently working great. I would like to show the user the image, in the album, so I need the image id to generate the url. I cannot figure out how to do this!! Below are the lines of code that upload/tag the photo, to my app's album. What do I need to do to get this image id? Thanks a lot! -Tim
$user = $facebook->getUser();
function post_image($facebook, $user,
$image_path){
try{ $tag = array(
'tag_uid' => $facebook->getUser(),
'x' => 0,
'y' => 0
);
$tags[] = $tag;
$image = array(
'message'=> 'Your Banner Photo', 'tags' => $tags,
);
$facebook->setFileUploadSupport(true);
$image['image'] = '#'.realpath($image_path);
$facebook->api('/me/photos', 'POST', $image);
echo "";
return true;
}catch(FacebookApiException $e){
echo $e;
return false;
} }
Sadly, you have to do it as a separate query. You have to get the users galleries (first graph API call). then find the gallery ID you want and request the photos (second graph API call) then parse through the photos to find the one you want. Finally you have to request that photo.
-------------------Update:---------------------------
I'm not a very proficient php developer, but i use facebook api all the time with javascript or actionscript. The basic premise is to call the graph api, and it will return a json object of the result. Use getFile or Curl to load the graph api responses.
You can test your graph api calls here:
https://developers.facebook.com/tools/explorer/?method=GET&path=663032752
so try and walk that through from the graph api. Get the user galleries, then get the photos, then get the one you want.
To get the albums, call
"https://graph.facebook.com/me/albums?access_token="._accessToken;
To get the photos in an album you call it using:
https://graph.facebook.com/"._albumID."/photos?access_token="._accessToken;
And then to get the individual photo you would get the photo's ID property and call that.
sometihng like:
"https://graph.facebook.com/".your_photo_id;
I think using CURL is a good approach, but I'm weak on php, so use what you are comfortable with.
You have the photo ID in facebook API response, if it is uploaded successfully:
$result = $facebook->api('/me/photos', 'POST', $image);
echo $result['id'];