Facebook insights return empty data - facebook

I ll try to explain what I want to do step by step.
I have a web page which post some things to facebook using his API. I have the next permissions:
Permission.USER_PHOTOS,
Permission.EMAIL,
Permission.PUBLISH_ACTION,
Permission.READ_INSIGHTS,
Permission.USER_BIRTHDAY,
Permission.USER_POSTS,
Permission.USER_LIKES
The user accepts these permissions at the facebook login. I post some info to facebook, the post is shared successfully, and I get the postID.
Then, I want to get the insights. Before coding, I am testing this on the facebook developer console. Can you please, tell me if I am miss doing something?
I choose the app
When I want to create the token, which is the right option? User Access Token, App Token or Page Token?
I get this result for the user access token
With the apptoken
and the fb_traceid value is this:
And this is not a page, then I can't try with the last option.
Could you tell me what I am doing wrong? Thanks in advance.

Please give a ad account for this as the app give its id for getting the insight

Related

Facebook Application Token

I create a demo application to request photos from facebook. I created an application token like this : 549933848476397|4a584ce5fda19cba2ed6630ed78ba8f4. But when use this request URL https://graph.facebook.com/1417833425116725/photos?access_token={app_id}|{app_secret}. It's does not work. Please help me. Actually When I use user token for this request, It's work ok.
If the Page is restricted somehow (age, location), you can only use a User or Page Access Token to get data like photos of the Page. The App Access Token got no relation to any User, so Facebook canĀ“t detect if the User is even allowed to see the Page.
I am 100% sure the Page is restricted btw, you get an "Unsupported get request" error when trying to access the Page ID directly with the Graph API, and that usually happens when the Page is restricted.
Just try another Page with that exact same App Access Token, for example:
/bladauhu/photos
...works without any problem. Another sign that your Page is indeed restricted.
TL;DR: For this specific Page, you MUST use a User Token or Page Token.

Facebook long-lived accesstoken for a page

I'm using a facebook extension in TYPO3 to pull out the facebook posts of a page. Therefor I need the accesstoken.
I googled around and found that I need a facebook app and I need to be administrator of the page.
Then I heard that I need to connet the app with the site, but how can I do this?
I also tried to get accesstoken:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
And then performing:
https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token& client_id={app-id}&client_secret={app-secret}&fb_exchange_token={short-lived-token}
... with this token but it says No user access token specified
Can someone help me step by step how to get the long lived token?
As you just want to pull, you really don't need a page access token. Until and unless you have a demographic or other restriction over your page. All the pages are Public and data over them can be easily accessed by using the App Access Token which is simply put
Your_App_ID|Your_App_Secret
first u need to get an API key from facebook, so here are the steps--->
http://www.shoutmeloud.com/how-to-acquire-your-facebook-api-key.html
& then u can access facebook API, these are docs provided by the facebook to use that API--->
https://developers.facebook.com/docs/guides/web/
This was my implementation (PHP):
$newposts = json_decode(file_get_contents("https://graph.facebook.com/YOURFBPAGE/feed&access_token=YOURAPPID|YOURAPPSECRET"));
Since I was only using this to make simple pull request of my feed posts this is the best way to do it. You don't have to deal with expiring access tokens. Just create your facebook App and get the ID and secret.

Can a page on a website get a facebook access token?

I'm fairly new to facebook development and I still get confused about the oAuth thing.
A client of mine asked me to show the latest posts, links and statuses of his facebook page to his website.
On the a php page on his website I'm creating a url
"https://graph.facebook.com/".$clientFacebookPage."/posts?limit=1&access_token= xxx
In order to json decode it and display the info I want, but I don't know how to get an access token. I generated an access token with the graph explorer that is tied to my name as a facebook developer but that expires in 2 hours.
There are many thing that confuse me already and I hope you can point me towards a solution
I've read the documentation but everything revolves around users getting logged on your app and you app posting. So my questions are:
Do I need to create an app to do a curl (requiring special permissions) using the http://graph.facebook/xxxx url?
If so, does the adming of the facebook page need to authorize with the app?
What do I need to do next? I can create a web page using the app id and secret. Does that mean that I can retrieve the info of the facebook page? How?
I know that the page needs an auth token to curl the http://graph.facebook/xxxx page and retrieve the data needed. Where can I generate it? Does the webpage need to generate it, or do I have (as the app developer) acquire the token and write it to my php code?
If I log out of the facebook, will the program/webpage stop functioning?
I hope I didn't confuse you.
Thank you.
The basic process for obtaining an access token for a Page is as follows:
1. Get a user access token for a User who is an admin of the Page
2. Using this User token, request graph.facebook.com/me/accounts and look for the correct Page ID in the list returned.
3. Grab the associated Page token from that ID
4. Use it to do Page stuff.
There is a newly launched Facebook docs guide which shows you how to obtain one of these access tokens in a step-by-step fashion:
https://developers.facebook.com/docs/howtos/login/login-as-page/
Hopefully that guide should help you.
I will also answer your questions in order:
Yes, you will need an app in order to generate access tokens to make API queries
Yes
This is in the guide linked above (start at the Getting Started if you need to create a way to get a User Access Token also)
Again, see the guide above
Yes, but you should follow the steps in this guide to generate a long-lived access token. Once you do that, any Page token you retrieve will last forever.

Get post from a Facebook Page without login

I am trying to get the post of a Facebook Page throw iOS API and I can't do it without login before (without access token). Is there any kind of solution to make this? Does anyone know it?
The App report me the follow error:
An access token is required to request this resource.
UPDATE
I generate one access token with this structure: APPID|APPSECRET and give it an expiration date. With this, I can access to the public data of my Page :)
Thanks,
David
Graph API Documentation seys:
posts [..] any valid access_token or user access_token
More informations you can find there http://developers.facebook.com/docs/reference/api/page/
Here is live example http://developers.facebook.com/tools/explorer/?method=GET&path=19292868552%2Fposts
+1 well... facebook data is all about "user", therefore you always need valid access_token
there are few exceptions though,
for example, you can display user profile picture without token,
see example;
https://graph.facebook.com/100001789213579/picture?type=large

Getting an APP_SECRET for a page, not an app?

Right now I am doing an http post request to post from a coldfusion file straight to my Facebook page. Right now, it is fully functional with the normal ACCESS_TOKEN for the page. My problem is, that to extend the life of the ACCESS_TOKEN, I need an APP_SECRET, which I don't know how to get for a page. Any tips? I really hope it's possible.
Any tips?
Tip 1: There is no such thing as an app secret for a page.
Tip 2: App secrets are for apps.
What type of access token is "normal"? How did you get it?
Read the "Page login" part of http://developers.facebook.com/docs/authentication/ for more information on how to correctly get a PAGE access token.
If you want to GET/POST/DELETE things via pages, you need a admin user's access token and the manage pages permissions, and then get an access token for each of the pages you want to 'manage' through the application, which it seems you must have previously done, to have access in the first place.
As far as I know, getting that page information again, would refresh a page access token, as long as your user access token was still up to date. I'd suggest re-using the code you have for the original call to get the page data/access tokens.