facebook feed metadata is not returned - facebook-graph-api

I am using FB Graph API to retrieve feed information. I would like to get metadata from the feed but I somehow cannot.
here is the url i use to get feed info:
https://graph.facebook.com/me/feed?metadata=1&access_token=MY_ACCESS_TOKEN
and here is the facebook example:
https://graph.facebook.com/331218348435?metadata=1&access_token=MY_ACCESS_TOKEN
so why in the former I have no metadata but in the latter I have?
Kind regards

You aren't getting the metadata because you have already selected a feed (Profile feed (Wall) - /feed ). To get metadata of the available feeds about yourself (/me) remove the /feed:
https://graph.facebook.com/me?metadata=1&access_token=YOURACCESSTOKEN

Related

Refreshing Video CDN link on Instagram with Graph API

Is there anyway to refresh the link of a video on instagram legally?
When I say legally I mean not via scraping but by following developer guidelines on https://developers.facebook.com/docs/graph-api ?
Suppose I was looking to get the following reel: https://www.instagram.com/reel/Cg3D38GBJwC/
I can get this raw video via the #NRL hashtag recent media which can be pulled with the following request:
17841564583099740/recent_media?fields=permalink,caption,media_type,media_url&limit=50
The video URL for this reel is:
https://video.cdninstagram.com/v/t50.33967-16/10000000_893382015382741_7795625665889045256_n.mp4?_nc_cat=104&vs=480915650532430_3376026638&_nc_vs=HBksFQAYJEdJQ1dtQURWOUt5MWhpd0RBQWdMUEhrOW9DOXNicV9FQUFBRhUAAsgBABUAGCRHSjJRdXhIa1cxMkd5RWNHQUM2WWRqa2xld1pRYnFfRUFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMRUAACagzLv9gdHNPxUCKAJDMywXQHRVul41P30YEmRhc2hfYmFzZWxpbmVfMV92MREAdQAA&ccb=1-7&_nc_sid=59939d&efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5jbGlwcyJ9&_nc_ohc=p8ThcVQ1vOQAX8njt1u&_nc_ht=video.cdninstagram.com&edm=AEoDcc0EAAAA&oh=00_AT8IoyJDBQLTOX1hXpby3lCT6cIiIcxuDTJUXaWlrrcCZA&oe=62ECFBB6&_nc_rid=e2b1a3ee71
We can initially obtain this URL by using the /recent_media endpoint, but after a day or so it will expire as it has the expiry embedded in the oe parameter.
Is there anyway I can refresh the link of this video by making another request?

facebook graph api pages post message

I wanted to make a facebook API request that will post a message to page that I am admin of. Here i found out how can i do that but after trying it out in facebook graph api explorer with this scheme:
graph.facebook.com/page-id/feed
?message=Hello&access_token=your-access-token"
assuming I have a developer account linked to my page and publish_pages and manage_pages permissions are enabled and page-id and acces-token are replaced with my real ones. The problem is that I get a response of latest post on that website, the same as if I would write just graph.facebook.com/page-id/feed and there is no new post on my page.
I dont know if the recent facebook API update removed or modified that or if its just not possible.
trying it out in facebook graph api explorer with this scheme
graph.facebook.com/page-id/feed?message=Hello&access_token=your-access-token
You are making a GET request here - and GET is for reading data, not creating it.
Creating data requires a POST request. So you can either switch the request method from GET to POST via the dropdown there, and then click + Add parameter to add your parameters and values;
or you can add &method=post to the end of your GET request query string here - that is a way the API offers to explicitly overwrite the request method in environments, where you can only make GET requests.

Facebook API query sub-object

I am interested in getting post lifetime insights for a given page in a single request.
A previous issue did half the work: Get posts with insights from a single API call - Facebook Graph API
Which allows me to get the insights for all posts in a single request by doing:
/{page-id}/posts?fields=insights.metric(post_impressions_fan,post_engaged_users)
But these are not always lifetime insights, and I would like to specify period=lifetime for the sub object.
How can I in Facebook Graph API do such?
I tried:
Adding insights.period(lifetime) which errors with: "Field insights specified more than once. This is only possible before version 2.1"
Doing insights only once as insights{metric(post_impressions_fan,post_engaged_users),period(lifetime)} but that failed with "Expected end of string instead of \"(\"."
You can use this API call to get lifetime post insight:
{page_id}/posts?fields=id,name,type,shares,link,permalink_url,created_time,picture,comments.summary(true).limit(0),likes.summary(true).limit(0),reactions.summary(true).limit(0)&period=lifetime&limit=100
use pagination to get all the post since maximum limit we can set is 100.

How to programmatically post like and comment an URL on facebook?

This is confusing. So just to clarify:
REQ #1: To fetch basic stats for a URL, you send GET request to:
http://graph.facebook.com/?ids=http://some.com
(alternatively, FQL can be used to fetch stats for a URL, but that doesn't return the OpenGraph Object)
REQ #2: To fetch comments for a URL, you do a GET:
http://graph.facebook.com/comments/?ids=http://some.com
REQ #3: To fetch likes for a URL, you GET:
http://graph.facebook.com/likes/?ids=http://some.com
But how do you comment on / like a URL programmatically?
I guess, likes can be created using Open Graph API, right?
https://graph.facebook.com/me/og.likes?object=1234
where 1234 is the OpenGraph Object ID of an article (as returned by REQ #1).
But this requires an approval process, the like action has to be approved by Facebook.
Is there a better way to do this? Can I use for example the Graph API for all these things?
My goal:
Currently I'm using the Facebook like button and comments plugin to create likes and comments. But these use the JS SDK, which is huge, and they generate a lot of external requests. I wanna get rid of them and just send an AJAX request to my server, which would then asynchronously talk to Facebook, and it would post the Like / Comment.
Is this possible?
Thanks in advance!
I read through the Facebook docs briefly and I don't believe you can do this other than the way you indicated with authenticating.
You should also take a look at this thread: 'Like' a page using Facebook Graph API
You would need to authorize every single user before he would be able to like something, and you would need to go through a review process on Facebook. And i am pretty sure you would not get the required permissions approved just because you want to get rid of the JavaScript SDK overhead, to be honest.
The Social Plugins are asynchronously, so the overhead for downloading the SDK is irrelevant as it happens in the background and it is non-blocking.
I have an idea, to do this. You can use long term access token, Once you login you receive short term token. After receiving short term token you need to request your long term access token. Save that token in DB or file.
Then you can use Graph Api, to make requests. This will eliminate the need for access requirement every time you request api.
Just use access token you saved before.
Refer this documentation from Facebook for further clarity.
https://developers.facebook.com/docs/facebook-login/access-tokens
Happy Coding!
Atul Jindal

Facebook Graph API Feed

I would like to show the posts from my Facebook page in another website using Graph API:
https://graph.facebook.com/[pageID]/feed?access_token=[accesstoken]
My question is, which access token should I use?
I have tried using my App Token, but I feel like I should be using other access tokens, how would I be able to obtain another Access Token?
Depending on your use case there a three different options when it comes to the question of which access_token to use:
Use any sort of access_token to get all posts that are public
Use an user access_token to get all posts visible to the user the token belongs to
Use a page access_token to get all posts
As far as I understand you, you want to get all posts from your page, regardless of any restrictions that may apply to a user that is viewing the feed (example: age restrictions, country restrictions). In that case use the page access_token for the page you want to get the feed from.
You can get the page token by calling /me/accounts [1], look for the page object and get the access_token for that page.
You can also read about it in the Graph API documentation [2] for pages.
[1] https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Faccounts&version=v2.0
[2] https://developers.facebook.com/docs/graph-api/reference/v2.0/page/feed#read