How can I submit an fql query using Facebook graph api with only a Facebook appId but without a user signing in? - facebook

I'm trying to use the new graph api for using FQL (the old api used https://api.facebook.com/method/fql.query?query=select%20like_count,%20comment_count,%20share_count,%20click_count%20from%20link_stat%20where%20url=%22facebook.com%22),
but it looks like I need an access token to use the new api ( http://developers.facebook.com/docs/reference/rest/links.getStats/).
Is there a way to get statistics on a link without having a user logging in (a functionality like the old api)? Can this be done using only a Facebook appId?
Thanks.

Just call this url and parse the json response (obviously replacing the google.com with your page):
http://graph.facebook.com/?id=http://google.com
This url doesn't not require any kind of access token.

Related

How to embed a Facebook Page's public info (like count) to a website using Graph API v2?

My previous implementation of using GET request to url https://graph.facebook.com/538726722826117 is broken now that Facebook has moved to Graph API v2 and requires an auth token for fetching this information. And as it is a website, I cannot embed a token which would have any more access rights than for reading a page's public information.
How to implement this rather simple task of getting a page's public like and check-ins count?
You don´t need to autorize, you can just use an App Access Token for the API call. Of course you should not use the Token on the client, but it´s perfectly fine to use it on the server. Make the API call with file_get_contents or curl - that is, if you are using PHP.
An App Access Token is very simple, it´s just the App ID and the App Secret, combined with a pipe sign: App-ID|App-Secret
More information about Tokens for the Facebook API:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/

how can get data from facebook api and write those data in my own database using web services?

For this task I have already created my own facebook application to get the API key and secret key. Can anyone explain the next steps that should be done to
1) Read from facebook API
2) Write my own database
by using web services
Thanks in advance!
A high level answer:
I'm assuming you want to use the authorization code OAuth flow (this means you want Facebook users to give you access to their profiles so you can grab data from there). If so, you need to bring up a web server and an application that will run your users through the Facebook OAuth flow. In case you just want to access Facebook with your own credentials you don't have to have a web server, simply use the client credentials OAuth flow.
So, Once you have a valid access token, you simply make calls to Facebook API using this token. using Facebook Graph API is simply a matter of calling URLs and getting the data as JSON.
You can test-drive the API here.
BTW, according to Facebook's platform policy, you're only allowed to store Facebook data for caching purposes.
Let me know if this helps.

How to implement Facebook Like in non-Javascript environments

I am working in mobile environments that do not support Javascript. Is it possible to add Facebook Like functionality to a page, probably doing server-side requests to Facebook?
For a more detailed example, if I go to http://ogp.me/, there is a Like button towards the bottom of the page. Clicking on that uses Javascript, optionally signing into Facebook if the relevant cookies aren't there.
I want to provide the same functionality, but without using Javascript (clue: need to support Blackberry browsers).
My intention was to use OAuth 2.0 with standard redirects, to get an access token with which to call the Graph API.
Once I have an access token, I was expecting something like
curl https://graph.facebook.com/me/likes?access_token={a-valid-access-token}&category=Website&url={url-encoding-of-url-to-like}
where the access token has the publish_stream permission granted to it. So to be more explicit:
curl https://graph.facebook.com/me/likes?access_token={a-valid-access-token}&category=Website&url=http%3A%2F%2Fogp.me%2F
That attempt returns me a 403 response, and I've not found anything else in the fine manual
The graph api does allow you to like a graph object (see Graph API Docs / Publishing) using:
https://graph.facebook.com/OBJECT_ID/likes
However the graph object must have an existing likes connection - and there's currently no way of creating such a connection via the graph api.
But if the like connection already exists you can get the pages graph object id using FQL:
SELECT id FROM object_url WHERE url='http://youtargeturl.lnk'

Remove the application from a user using graph API

I am developing a facebook application, I want to remove my application from a user using Graph API, is there any way to do this.
When the user is connected, do:
FB.api("/me/permissions","DELETE",function(response){
console.log(response); //gives true on app delete success
});
I got this working with a serverside request using Using ASP.Net with Facebook’s Graph API and OAuth 2.0 Authentication this article as reference you get a auth token then when they redirect back to your callback you post a delete request to the graph url e.g.
"https://graph.facebook.com/person_id/permissions?access_token=token

Facebook Connect Graph API - Why Can't I Retrieve All User's Details?

I feel like every second question i ask here is relating to Facebook Connect - that says a lot about their API. Anyway, that's politics, i digress..
I'm trying to pull back user details from the Graph API for use in my application (which is an FBML external website - JavaScript SDK for authentication).
I have requested the following permissions from the user: (using the regular dialog)
publish_stream
email
This works, and allows me to post to the user's wall, and grab their email from the Graph API.
But when i do a HTTP GET Request to the following URL:
https://graph.facebook.com/uid?access_token=oat (where uid = the user id of the user i'm attempting to grab details for, and oat = the OAuth token i have).
All that comes back in the JSON is the User ID (which i already have, since im putting it in the URL), and the email.
Why can i not get things like first name, last name, locale, etc?
Am i using the wrong URL? Is my OAuth token wrong?
I'm getting the OAuth token from here:
https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=myappid&client_secret=myappsecret
UPDATE:
It looks like the issue is my OAuth token.
Because when i go to the docs: http://developers.facebook.com/docs/api
And use the sample OAuth Token for the user im trying to retrieve, it gets all the details.
Anyone know what is wrong with my OAuth token call?
So, i was using the wrong URL for the OAuth Exchange. It needed to be this:
https://graph.facebook.com/oauth/exchange_sessions?type=client_cred&client_id=myappid&client_secrete=myappsecret&sessions=userseshid
The URL that i WAS using was as per the doco, the above one that works is nowhere to be found.
I'm at the point with FBC that i no longer care about the how, if it works, be thankful that it does even that and move on.
EDIT:
Also, i was wondering why the Graph API calls would "stop" working for no reason.
The answer is i needed to compare the Session Key used to obtain the OAuth token, with the Session Key currently in the cookies. If they are different, i needed to get a new OAuth token.
The session key used for any OAuth token is part of the actual OAuth token:
aaa|bbbb|cccc
Where bbbb is the session key. So i just compare that before doing any Graph API calls.