What I am trying to do is for the currently authenticated facebook user get their latest posts. I get error
An active access token must be used to query information about the current user.
The token is active in that it lets me get data for other users, just will not let me get data for current user? It used to work with old version of skybrud. Any ideas?
It should still work, but I will check if there is a bug in the latest code.
How have you obtained the access token? If you have used the login dialog in my package, you have obtained what is called a user access token, and it should work fine. If you have obtained the access token in another way, you may have an app access token instead, and you can't use "me".
I obtained the token using https://developers.facebook.com/tools/accesstoken/ the reason for this was because user access token expires after 60 days i think, weird thing is this used to work fine with old version of skybrud. With the token i need to do both getting other users page stats (works fine) and current users latest posts, this is failing.
Are you sure you're not using an app access token?
The access token page will list a user access token and an app access token for each of your apps.
The user access token is bound to your user, and therefore has a user context (means that you can use "me"). The downside is that the token will expire after 60 days.
The app access token is bound to your app, and therefore doesn't have a user context (means that you can use "app" rather than "me" - which is not the same). App access tokens will not expire, so it seems this is what you're using?
I'm pretty sure the logic regarding this hasn't changed in Skybrud.Social. At least it still works when I test using few of the user access tokens listed on the page.
Yes it is an app access token, do i then need to have 2 one user access one so i can get current users posts and one app token so i can othe users pages data? My one concern is that the user one expires after 60 days is there another way round this?
Go to the Graph API Explorer and enter the user access token listed for your app at the access token page. Then make a call to /me, and manually read the ID of your user (and then hardcode it in your code or something like that).
In your code, then use the app access token (again from the access token page) to make requests to the API.
Users have unique IDs from app to app, so it is important that both the user access token and the app access token belongs to the same app. Facebook does this to protect the privacy of their users.
Anyways, if possible, I would suggest creating a page instead. Pages are easier to work with in the API - among other things because pages have global IDs (the same across all apps), and you can give a page an alias (eg. you can call /umbraco/posts).
Doh of course KISS keep it simple stupid lol, I am certain that the posts we want are from facebook user with page its for a big company. So I will do that.
Facebook me posts
Anders,
Using all the latest skybrud social and i can get facebook page stats for a given user. What is not working however is
What I am trying to do is for the currently authenticated facebook user get their latest posts. I get error
An active access token must be used to query information about the current user.
The token is active in that it lets me get data for other users, just will not let me get data for current user? It used to work with old version of skybrud. Any ideas?
Regards
Ismail
Hi Ismail,
It should still work, but I will check if there is a bug in the latest code.
How have you obtained the access token? If you have used the login dialog in my package, you have obtained what is called a user access token, and it should work fine. If you have obtained the access token in another way, you may have an app access token instead, and you can't use "me".
Anders,
I obtained the token using https://developers.facebook.com/tools/accesstoken/ the reason for this was because user access token expires after 60 days i think, weird thing is this used to work fine with old version of skybrud. With the token i need to do both getting other users page stats (works fine) and current users latest posts, this is failing.
Regards
Ismail
Hi Ismail,
Are you sure you're not using an app access token?
The access token page will list a user access token and an app access token for each of your apps.
The user access token is bound to your user, and therefore has a user context (means that you can use
"me"
). The downside is that the token will expire after 60 days.The app access token is bound to your app, and therefore doesn't have a user context (means that you can use
"app"
rather than"me"
- which is not the same). App access tokens will not expire, so it seems this is what you're using?I'm pretty sure the logic regarding this hasn't changed in Skybrud.Social. At least it still works when I test using few of the user access tokens listed on the page.
Anders,
Yes it is an app access token, do i then need to have 2 one user access one so i can get current users posts and one app token so i can othe users pages data? My one concern is that the user one expires after 60 days is there another way round this?
Regards
Ismail
Here is what I would do:
Go to the Graph API Explorer and enter the user access token listed for your app at the access token page. Then make a call to
/me
, and manually read the ID of your user (and then hardcode it in your code or something like that).In your code, then use the app access token (again from the access token page) to make requests to the API.
Users have unique IDs from app to app, so it is important that both the user access token and the app access token belongs to the same app. Facebook does this to protect the privacy of their users.
Anyways, if possible, I would suggest creating a page instead. Pages are easier to work with in the API - among other things because pages have global IDs (the same across all apps), and you can give a page an alias (eg. you can call
/umbraco/posts
).Anders,
Doh of course KISS keep it simple stupid lol, I am certain that the posts we want are from facebook user with page its for a big company. So I will do that.
Regards
Ismail
Anders,
That works a treat many thanks once again.
Regards
Ismail
is working on a reply...