How to get URLs from ad creative in Facebook API - facebook-graph-api

I need to get urls from my ads, and when i using code from FB Api reference and try to get object_url, i get this error
"message": "(#100) Tried accessing nonexisting field (object_url) on node type (Ad)"
All i can get is the name of my adds. I get the page token from this link - https://developers.facebook.com/docs/pages/access-tokens/ and it doesn't help me. So what i am doing wrong?
Also i tried this code https://developers.facebook.com/docs/marketing-api/ad-creative/asset-feed-spec/ and i also getting message that Tried accessing nonexisting field

Related

Instagram Graph API when run through postman giving error : Invalid protocol: "https:

I am new to Graph API as well as facebook developer account, new to postman.
I generated access token as well as linked my Instagram to my test app, also given required permissions.
After this, I copied my page Id and access token in the URL on postman but it's giving me error.
URL looks like this :
"https://graph.facebook.com/v14.0/xxxxxxxxxxxxxx?fields=instagram_business_account&access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(Removed page Id and access token of course)
Found nothing on google as well.
What is wrong here ?
Found the issue! There was " at the start of the URL!
Once I removed the ", it worked as expected.

How to get a valid access token to query search result from Facebook graph API

I want to collect all the Facebook link from Facebook search function. What I'm using here is the Facebook graph API tool.
If I want to query the data for a keyword, for example: "limited";
I will use the URL:
https://graph.facebook.com/v11.0/search?q=limited&access_token={my_access_token}
My image
However, I got the result as in the image. When I tried to create a workplace app and tried to get the access token of that app, I got the message as in the second image.
Error message when getting the access token of a workplace app
What I need now is an access token that has the permission to retrieve the data from the Facebook search. After that, I can use python to handle the rest.
Please help me out, thank you very much!

Facebook Graph API can't get shared post content but the original

I'm trying to get the content of the a facebook post using facebook graph API v2.9. I get error in the case of my friend shares a video from another page.
https://graph.facebook.com/v2.9/743711040_10155091021136041?fields=source,created_time&access_token=[user_access_token]
Where the '743711040_10155091021136041' is [userid_postid] and the user access token has the the following permissions:
"public_profile", "user_friends", "user_posts", "email"
The response I get is:
error: {
message: "Unsupported get request. Object with ID '743711040_10155091021136041' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
type: "GraphMethodException",
code: 100,
fbtrace_id: "BF9o+18whmD"
}
But when I try with the original page post that my friend has shared:
https://graph.facebook.com/v2.9/960234257424791_1318359071612306?fields=source,created_time&access_token=[user_access_token]
Where the '960234257424791_1318359071612306' is [pageid_postid] I get a success response:
source: "https://video.xx.fbcdn.net/v/t42.1790-2/18524911_304316830006313_7455758837228765184_n.mp4?efg=eyJybHIiOjMzMSwicmxhIjo2NTgsInZlbmNvZGVfdGFnIjoic3ZlX3NkIn0%3D&_nc_pt=1&rl=331&vabr=184&oh=3b3077d9a1e2b645f1531d6562ee4da8&oe=5942A4AF",
created_time: "2017-05-15T11:24:41+0000",
id: "960234257424791_1318359071612306"
Please tell me if I'm missing something? Need another permission? Or what could be the problem?
Update
If it is really impossible to get post details of a friend that hasn't authorize my app, then can I at least get the original post_id of the page post that my friend has shared? This will be very helpful.

Retrieving albums from age-restricted (alcohol) pages results in "An unknown error occurred"

I've noticed when doing a Facebook Graph API call to retrieve a list of photo albums on an age-restricted page the following error occurs:
{error_code: 1, error_msg: "An unknown error occurred"}
I've tried both the JS API and the PHP API, same results.
For testing purposes, I am using an age-restricted page I created myself (permission set to Alcohol-related). I also have double checked that I am using a valid auth_token that has full permission to read and write photos to the page.
$albums = $facebook->api('/me/albums', 'GET', array(
'access_token' => 'XXX'
));
Please note the same code works fine on non-age restricted pages.
I should also mention, if I grab an album_id manually from Facebook, I have no problems posting photos to that album. The problem only seems to be with listing the albums.
Is this a bug on Facebook's side, or is there an extra step one must take for age-restriced pages?
Since the page is age restricted the user viewing this album should pass the age restriction check. Verify that the user viewing this passes that restriction.

facebook-graph-api Getting "Invalid OAuth access token." after 3 https calls

Hi im trying to get group wall feeds , im using desktop application to get all the feeds but after 3 https api calls im getting :
{"error":{"type":"OAuthException","message":"Invalid OAuth access token."}}
this are my calls:
https://graph.facebook.com/175923872448029/feed?access_token=355xxxx|2575b794cd858xxxx-55xxx13|N-oGZ6q2sNDNgxxxxU-TDw&distance=100000&limit=30&offset=0
https://graph.facebook.com/175923872448029/feed?access_token=355xxxx|2575b794cd858xxxx-55xxx13|N-oGZ6q2sNDNgxxxxU-TDw&distance=100000&limit=60&offset=30
https://graph.facebook.com/175923872448029/feed?access_token=355xxxx|2575b794cd858xxxx-55xxx13|N-oGZ6q2sNDNgxxxxU-TDw&distance=100000&limit=90&offset=60
https://graph.facebook.com/175923872448029/feed?access_token=355xxxx|2575b794cd858xxxx-55xxx13|N-oGZ6q2sNDNgxxxxU-TDw&distance=100000&limit=120&offset=90 <-- this call gives me the error
the weird thing is that when im take this https call the one failed and run it in firefox , it does return me result any idea way ?
You do not have proper authentication set. See: http://developers.facebook.com/docs/authentication/
For my case, I actually did it this way:
I have tried several ways, and I got the invalid OAuth access token error too.
After getting my page access token using the Graph Explorer, I wrote this code:
pagetoken = 'EAAOSZBmdTKBMBAIf1FrTGmapagVZAvwdlrwSWNc3EZCOTXQ90Im9u'
mylikes = "https://graph.facebook.com/me?fields=likes.summary(true)&access_token"+pagetoken
I then noticed an equal sign was missing, and that fixed my invalid OAuth access token error.
pagetoken = 'EAAOSZBmdTKBMBAIf1FrTGmapagVZAvwdlrwSWNc3EZCOTXQ90Im9u'
mylikes = "https://graph.facebook.com/me?fields=likes.summary(true)&access_token="+pagetoken
I hope it helps anyone with the same issue.
That happened to me for hours:
facebook-graph-api Getting “Invalid OAuth access token.”
In my case, the application was re-directing to a local address, and the URL authorized by Facebook was not local, so Facebook was not login me in.
The access_token for the user I was using was some old access_token kept in the script by window.sessionStorage. So I thought I was using the right access_token, but I was not.