Remove the application from a user using graph API - facebook

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

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/

Can i pull events from a facebook page using REST API

I want to pull events from any facebook page(given a page id) using REST Api. I am writing a server application and there is not facebook user login that we are using.
You could do this with an eternal Page Access Token via the /{page_id}/events edge.
See
https://developers.facebook.com/docs/graph-api/reference/page/events/

Facebook login with passport.js, sails.js API and ember.js

I'm setting up this Sails project where I use PassportJS, via sails-generate-auth, and JWTs - using this as a guide - to login. I'm trying to decouple the api from the Ember app as much as I can so I can use the same API for iOS, etc. Since passport uses callbacks to handle Facebook auth, how can I login via AJAX?
I'm able to successfully login to Facebook via passport js using an AJAX GET to /auth/facebook like so
var url = config.api + '/auth/facebook'
var controller = this;
Ember.$.get( url, function ( data ) {
// This is never called because Facebook redirects
localStorage.private_token = data.token;
controller.transitionToRoute('profile', data.user);
});
but then when Facebook redirects, it goes back to the API, not the frontend app. But if I configure the backend to redirect to the front end app after the callback, I have a dependency on the front end app that I want to avoid. I've never done Facebook auth before but I've used API tokens for a while now.
Is there any way to do what I'm trying to do? Or should I just redirect to the front-end app from passport.callback?
Update
After a bit more searching, I came across this answer: passport.js RESTful auth
It seems that I cannot achieve what I want since Facebook only exposes a redirect-based authentication, not an async or JSON one. Good to know...mark as duplicate if you'd like.
Your application must also implement a redirect URL, to which Facebook will redirect users after they have approved access for your application.
From Passport.js Facebook guide (Look at Configuration).
So you have to set your ember app state/url as redirect url e.g. http://localhost/#/welcome

Facebook app with REST API

Can I create a new Facebook app to use old REST api for user authentication. I would like to use the method auth.login for user authentication. Is it possible to use REST api with new facebook apps?
The Facebook's legacy REST API does not work for new Facebook apps registered after Apr/2013. However, REST API is still supported for existing Facebook app created before Apr/2013.
You will get "Error 3 : Application does not have the capability to make this API call" when trying to access REST API from the new Facebook app.
For newer Facebook app, please use Graph API to achieve the similar functionality as in the legacy REST API.
The REST API is deprecated now. Blog post here: https://developers.facebook.com/blog/post/616/

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

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.