I have several advertising companies and a test application on Facebook (status: in development). When i request meta information on ad objects, I normally receive it. But when I try to get insights on campaigns from API, only an empty array comes back.
{ "data": [] }
The access token has all the necessary permissions. At the same time, insights from the sandbox comes in well through the same methods (only access token also from the sandbox).
What can be wrong? Does Facebook really allow get insights about real ad campaigns only for published Facebook applications?
Related
I like to get posts and insights from Instagram users, ideally with only one login.
From what I’ve seen, I have to use two different APIs:
Instagram API, api.instagram.com for login and graph.instagram.com to get the accounts posts
Facebook API, graph.facebook.com to get the insights
As it seems I can’t use Instagrams token for Facebooks API and I also don’t get direct access to Instagram accounts via Facebooks API. Also there might be Instagram accounts without connected Facebook account.
So I’m wondering:
Is there an option to access Instagram insights just via Instagrams API?
What would be the best solution to get Instagram user ids with Facebook token (get user token ➝ get Page token ➝ get connected instagram accounts)?
I have facebook app with status Live and available to all users. When I login through this app on my site I get access_token for my facebook user. And with this access_token I can read with Ads API next methods (for my own ad campaigns):
/me/adaccounts
/act_<AD_ACCOUNT_ID>/agroups
But when someone else login on my site (and confirms all permissions) and I get his/her access_token I can't perform second api call. I get this error (#10) You do not have sufficient permissions to perform this action. But I can get account ids. So, first method works, second not. How to fix this?
P.S. Status of app in App details tab is Unapproved (lightblue circle).
P.P.S. After adding that user to app's developers all is ok with second method (adcampaigns).
Your app is most likely in development Tier for Ads API Access
https://developers.facebook.com/docs/reference/ads-api/access#limits
You need to apply for higher levels
Some time its happen when you reach the limit of Marketing API Access.
https://developers.facebook.com/docs/marketing-api/access
Suppose your application have basic Marketing API Access Levels (In Basic, further test, iterate, build an app with up to 25 external accounts.) and you reach limit of ad account. When your new ad account(s) will request Facebook Ads API access then facebook send you mention error response.
To check your ad account(s) and their limit
Facebook APP -> Settings -> Advance tab -> Advertising Accounts section -> Ads Api button
https://developers.facebook.com/apps/YOUR_APP_ID/settings/advanced/
I've seen several questions regarding this topic in stackoverflow, but I could not find a bottom-line answer to this question.
I have a Facebook app.
I have a website to which users register using their FB account.
I would like to be able to get public posts from users' feeds using Facebook's API when the feeds update, even when the users are not logged into FB or into my website.
I was able to successfully subscribe to FB real-time updates.
I was able to see a user's public posts in http://www.facebook.com/<uid>/feed.
I tried to access https://graph.facebook.com/<uid>/feed - I got "An access token is required to request this resource.".
So I created an app access_token (using https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=APP_ID&client_secret=APP_SECRET).
I then tried to supply the app access_token I received when accessing the user's feed: https://graph.facebook.com/<uid>/feed?access_token=APP_ACCESS_TOKEN.
This time, I didn't get an OAUTH error, but just an empty JSON array: "{ "data": [ ] }"
The user in question gave the following permissions to my app: "email,read_stream,export_stream" (using the scope parameter in the FB.login API call).
At the moment it seems to me that the only way to get a user's feed via API is to wait for the user to log back into my website, get a user access_token, and only then make the calls.
I would appreciate it if anyway could confirm the above conclusion, or even better: let me know what I'm doing wrong...
Thanks!
Don't think as developer yet. I'm a Facebook "normal user" and I'm logged. Then I access a friend 'X' profile. As a friend, I can see all the friends of friend X through this url:
https://www.facebook.com/friendx/friends
Fine... I can close the browser and, when I open it again, I can access the same url and see my friend's friends. And it's fine, because there is a cookie telling the server who I am.
But now, I'm still logged and I wanna retrieve all the friends of friend X throught graph api request, so i access this url:
https://graph.facebook.com/friendx/friends
And the error is, according to the documentation, expect:
An access token is required to request this resource.
I can't understand why facebook needs an access token. I'm logged in both cases. That cookie, in the second situation, is useless when I try to access the same information through graph api request.
What I wanna mean is: I don't wanna parse a whole html page to know who are friends of my friend. Parsing json is much easily.
The Facebook API requires authentication from the user to make that GET request, therefore you need an access_token saying that the user gave permission for you to access their friends list.
You cannot get an access_token from your cookies as it has to be generated via the API after the user approves your app.
If you want to test the graph API consider using the Graph API Explorer to generate an access token and generate the request but you should not use this as a solution to your answer.
consider reading the facebook documentation on access_tokens to further understand how the facebook API and authentication work.
The facebook GraphAPI doesnt allow us to collect the data which belongs to someone else. As you said you can access the friend's friend but at that time you are not collecting data for personal use, so that is allowed. That data is public so you can access, but I certainly doubt that they do allow us to access that data through GraphAPI or any other API. Also scrapping Facebook data is not against the facebook policies.
On the documentation page for Facebook Graph API there are a lot of example links such as https://graph.facebook.com/me/likes?access_token=SOME_AT
Could anyone explain how the access_token for these links are generated?
All I've read in the documentation were about getting access_token only for applications, but on that page everyone could get an access_token without one.
You can use the graph API to get public information. People set privacy settings on facebook, so to prevent social freaks from stalking you, they(fb) created Autorisation.What I believe is that on the documentation, they are generating the access token using the Developers App. You can generate this Access token by making an application and asking a user to Authorise your application to access his data using OAUTH dialogs. Usually people reading at developer.facebook.com have enabled the Developers app so it easily opens your information.
The Graph API as such allows you to
easily access all public information
about an object. For example,
https://graph.facebook.com/btaylor
(Bret Taylor) returns all the public
information about Bret. For example a
user's first name, last name and
profile picture are publicly
available.
To get additional information about a
user, you must first get their
permission. At a high level, you need
to get an access token for the
Facebook user. After you obtain the
access token for the user, you can
perform authorized requests on behalf
of that user by including the access
token in your Graph API requests:
The access_token in these links are generated using your Facebook identity and an application ID (presumable associated to "developers.facebook.com"). If you go to the same page with another Facebook account, you will see different access tokens.