I'm having difficulty finding a way to get a page access_token from FQL.
http://developers.facebook.com/tools/explorer?method=GET&path=me%2Faccounts
- This is the graph call with the page access_tokens included. The trouble is that I need the access tokens for a multiquery call and would love to not have to make a separate call just for the access tokens then call the same info for my multiquery.
http://developers.facebook.com/docs/reference/fql/page_admin/
- This doesn't contain the access token, although it mentions contains the same data as the /user/accounts graph api call.
http://developers.facebook.com/docs/reference/fql/page/
- This also doesn't seem to include the page access token.
Has anyone had luck or found a way to get that token through FQL?
Thanks for your help!
It is possible!
SELECT access_token FROM page WHERE page_id={id}
It's not possible to get the access token from FQL, you can only do it via Graph API calls.
FQL is for queries from tables.
Graph API is for GET, POST and DELETE requests
Related
I'm trying to delete a comment using a Graph API call.
https://graph.facebook.com/[comment-id]?access_token=[access-token]&method=delete
However, in terms of access-token, I'm not sure which one to use? I have used my App's "User Access Token", "Page Access Token" and "App Token". It doesn't work for any of these.
[PS, my app has all permissions, and I have even submitted it for review]
I just wanted to know if it was even possible to delete a comment which was not posted by the application? (Because I see that Delete is only allowed for page access tokens).
So, please do let me know if it is possible to delete a comment from a user's posts. And if so, which access_token to provide.
The docs list all the neccessary Access Tokens and permissions:
https://developers.facebook.com/docs/graph-api/reference/v2.10/comment#deleting
I tried it with a user profile, it does not seem to be possible to post comments or delete them - no matter if was created by the App or manually:
Publishing comments through the API is only available for page access
tokens
For Pages, you need to use a Page Tokens with the neccessary permissions according to the docs.
It looks to me that you're doing an HTTP GET call and just putting &method=delete at the end. That's not how it works
You should do an HTTP DELETE call. So instead of doing something like $.get(...), you should do $.ajax with type: 'DELETE'
Also, make sure your token has publish_actions permission
I need to retrieve a facebook page's list of posts (feed) using their javascript SDK, just like they explain in their docs: https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed
/* make the API call */
FB.api(
"/{page-id}/posts",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
I need it to be my website's "news section", so users should see it even if they are not connected to facebook.
The problem
Cool, but there is a problem... It returns: An access token is required to request this resource.
Holy cow... I'd like to get some access token for you #facebook, but my app doesn't make use of your authentication tools/plugins.
ANYWAY, I tried with FB.getLoginStatus(); but doesn't work, because the only way it can return an access_token is if the user is actually connected to the application. My users may not even be logged to facebook!
So, ¿How can I get an access_token to be stored into a variable, and later be used to get /{my-page}/posts?
I've already payed a look to this SO question, but it doesn't solves my problem, simply because there are no such "generic tokens".
I've also read https://developers.facebook.com/docs/facebook-login/access-tokens/ and that also relies on tokens generated through facebook login methods... So, can't I display a list of fb page's posts in my website, without being connected into facebook, hence an application?
ADD: My app is build with angularJS, I'm not dealing with server-side code. I shall rely purely on javascript methods.
You could either use an page or an app access token, but as you'd be using them on the client-side, neither of them are an option.
See
https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens
https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens
Note that because this request uses your app secret, it must never be made in client-side code or in an app binary that could be decompiled. It is important that your app secret is never shared with anyone. Therefore, this API call should only be made using server-side code.
I'd strongly recommend to build a simple server-side script (PHP for example) to proxy the request to the Graph API. You could then call this via AJAX for example and load the posts asynchronously (and alse get rid of the FB JS SDK!). There is NO way to handle this in a secure manner if you don't want to use FB Login for all of your users (which also doesn't make much sense IMHO).
I think it's straightforward :)
Since pages' posts are always public, it only needs a valid access token to retrieve page posts.
Quoting what you've written:
So, ¿How can I get an access_token to be stored into a variable, and later be used to get /{my-page}/posts?
You only require an access token.
My suggestion would be;
- Generate an access token for yourself (no extra permission needed)
- request page-id/posts
This way you don't require other users to be connected to facebook, you can simply requests page-id/posts to retrieve posts with access token you generated for yourself.
I hope it solves your problem :D
TIP: As long as posts are public, you only require a valid access token, it doesn't need to be user or page specific.
Consider that I am owner of http://ethernalsite.com
On my website i've added google analytics script and it's happily collecting data about my precious visitors.
I would like to create page views counter. How I can fetch data from my own account?
I mean, from site's account on which data is collected.
I've tried this:
create browser token on google's developer console and allow access for ethernalsite.com/*
I've got something like: xxxxSyCl5wAzQVSxxxxxKHFcxn6Uxzi-skoFZgo
make ajax get on client(javascript) side: https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A00263622&metrics=ga%3AuniquePageviews&start-date=2014-08-19&end-date=2014-09-02&max-results=50&key={KEY}
I've got the following response for ajax get query(firebug)
"NetworkError: 401 Unauthorized - https://www.googleapis.com/analytics/v3/data
/ga?ids=ga%3A00263622&metrics=ga%3AuniquePageviews&start-date=2014-08-19&
end-date=2024-09-02&max-results=50&key=xxxxSyCl5wAzQVSxxxxxKHFcxn6Uxzi-skoFZgo"
With content:
{"error":{"errors":[{"domain":"global","reason":"required",
"message":"LoginRequired","locationType":"header","location":"Authorization"}],
"code":401,"message":"Login Required"}}
In the future I would like to cache this value in the server side and allow client to fetch this data from my server every minute. If you also have tips about solving this problem using python i would be grateful.
The Google Developer Console will only give you the CLIENT_ID and CLIENT_SECRET. With these keys you will be able to generate an ACCESS_TOKEN and you will have to change your query string to
?ids=ga%3A00263622&metrics=ga%3AuniquePageviews&start-date=2014-08-19&end-date=2024-09-02&max-results=50&access_key=xxxxACCESS_KEYxxxx&_src=explorer
Simple dimple one here- trying to use Soundcloud's resolve method to retrieve a JSON feed of track data for a private set.
http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/myUser/private-set
resolve returns a 401 unauthorized error, as it should
http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/myUser/private-set&client_id=myClientID
resolve returns a '404' not found error. it should be 301 redirecting to the authorized JSON feed for the track, such as http://api.soundcloud.com/tracks/49931.json in the doc's example
I've created an App
I'm using the App's Client ID
I've enabled App access in the Set's edit menu
I'm formatting it as per the API docs
Am I missing something here?
So after some testing I've confirmed that the issue is related to the fact that you're trying to request a private set. Because the set is private, you would need to first go through SoundCloud's OAuth 2 authentication process before being able to access the set.
Try resolving the set url with the url found in the share dialog of your set. This url contains a secret token that can be used to access a private set without logging in.
Not sure how far this'll get you if the tracks in the set are also private, though. And like bbone mentioned, you'll be exposing this secret token, which may or may not be a problem.
Im trying to use javascript to determine if a user is a fan of a page that i've created on my account.
I found the facebook graph api which looks like just what i want. However it appears for some functionality i need an access token.
Here it says I can just http get my /user_id/accounts page with the manage_pages permission and it will list the access token for each page.
But when i submit https://graph.facebook.com/myuserid/accounts&scope=manage_pages i get "OAuthException : Access token is required to request this resource."
I also tried from this answer, but then i get "An error occurred, please try later".
Any suggestions most welcome.
You will need an access token to retrieve any information that is not public on facebook.
You can read up on this page about authenticating a user. Once your user is authenticated you can retrieve the access token and use it in your future requests (for that user)..
eg:
https://graph.facebook.com/{YOUR_USER_ID}/accounts&access_token={YOUR_ACCESS_TOKEN}