i am learning about handling the graph api in python via the FacePy module.
I am just curious as to see if it was possible to delete friends via the Graph API?
Because of possible misuse that might happen, feature like deleting friends via Facebook is not available. You can although send Friend Requests but the app should not use this feature to encourage users to friend other users that they are not connected to in real life.
Related
I am new to web programming- I've recently been familiarizing myself with the webapp2 framework. I'm trying to start building a website, and would like users to login to the site with Facebook and I'll need access to their friends list. I've been trying to find a way to do this- I found out about OAUTH2, and I think this may be a way to do this. All the tutorials for python and OAUTH2 that I've found have been using the google API, I'm not sure if it's any different, but I haven't been able to get it to work.
Does anyone have sample code they can post that uses OAUTH2 (or anything else) to get users to sign in through Facebook? Or any good resources that can help me with this?
Your app needs to authorize users with Facebook, since there's where the resources you need are (e.g. friend lists).
This is a classic use of OAuth2 and you don't have a way around it, because FB implements this protocol.
My suggestion is that you look at the Google sample and then adjust it for FB API. The important changes are:
The endpoint URLs (e.g. authorize, token and user profile
The scopes that define the extent of permissions you are requesting (e.g. list of friends)
The user profile (e.g. the information returned by FB on a user: name, e-mail, etc)
This is a very simple sample that does this in Python. It was meant to run in Google App Engine. The only caveat is that it uses our own library to encapsulate the flow. But you can use it to study how the basic protocol works. Run the live demo and turn on dev tools on your browser to see the network activity.
You will notice that OAuth2 is a rather simple protocol, using simple HTTP requests.
I have designed a Facebook application and need to add OAuth, Open Graph for complete functionality. Considering that I know nothing about Open Graph and little JS, I'd like to use a small wrap-up (python lib) which will provide the those features..
I searched over Google, stackoverflow and found few projects which provide some cool features but I am unable to choose..
python libs:
django-social-auth
fandjango
facepy
pyFacebook - I think this doesn't offer OAuth.
I also use Google Data API in my project. So, the better option would be django-social-auth but I am not sure if I can do Open Graph with it..
Can anyone tell me what is the best, maintained, good lib?
(Please do mention if its not in the above list)
django-social-auth is really great if you want to build a website that allows users to log in with Facebook, but if you're building an application on Facebook.com you probably want to use something like fandjango. Either way, you will need a different kind of library (like, say, facepy) to interact with Facebook's API once you've retrieved an access token from the user.
Full disclosure: I am the author of fandjango and facepy.
I would highly suggest django-social-auth. Any library than can parse JSON will support Open Graph as FQL and Graph API data can all be retrieved from Facebook's API (REST).
Good luck!
I am trying to make a little desktop alert script that will tell me if there is a new post on my Facebook page's wall. It would be nice to see if I'm getting any new likes as well but really I mostly want to access my wall feed.
I don't need help parsing it or anything like that (I'm literally just going to compare a stored feed with how it is currently to see if there is a change once every 2 minutes or so) I just need to know how to access it.
You can pull the content in your profile feed (wall) as a JSON object using the Facebook Graph API. You can check out the details here: http://developers.facebook.com/docs/reference/api/
Like McOcoonor said you should use the Facebook Graph API as documented here:
http://developers.facebook.com/docs/reference/api/
If you want your application to have continuous, long-term access to your Facebook information then you need to add the offline_access permission flag to when the app requests the access token. Documented here:
https://developers.facebook.com/docs/authentication/permissions/
For doing this all in Python you might be interested in this S.A. Question: Facebook Graph API and Django.
You can try to use a library to access your facebook wall. It requires register your application on facebook but it's easy to do http://developers.facebook.com/setup/
Then you can check out a python wrapper to the facebook api -> http://code.google.com/p/pyfb/
Or download it from pypi -> sudo pip install pyfb
If you are using facebook sdk for python (https://github.com/mobolic/facebook-sdk), you can use get_connections method(http://facebook-sdk.readthedocs.io/en/latest/api.html#get-connections)
import facebook
graph = facebook.GraphAPI(access_token)
feeds = graph.get_connections('me', 'feed')
I'm starting a project using the XMPP protocol and haven't done anything with it thus far. I would like some advice/direction in regards to my questions below.
At the present moment, I know Facebook's Chat API says to use PyXMPP and pyFacebook, which is what I will be using initially. However can someone give me an idea as to how to connect Facebook chat with Gtalk; using their example script, located here:: http://developers.facebook.com/docs/chat/
I see that they mention API keys, where exactly do I retrieve the API keys from? Thanks.
You need to register your application at http://developers.facebook.com/apps and get the API keys. Both Gtalk and Facebook chat are built on XMPP protocol. So you can set up an XMPP chat client which will connect to both.
Refer to the book written by Jack Mofitt: http://professionalxmpp.com/
It talks about setting up the chat client. Also the documentation in the Developers forum is bad. Check out this thread from the old forum http://forum.developers.facebook.net/viewtopic.php?id=51892
Yes you can connect using digest MD5, where you need to pass the username and password. Go through the XMPP protocol to get a better understanding on digest MD5.
I am building a website for a comedy group which uses Facebook as one of their marketing platforms; one of the requirements for the new site is to display all of their Facebook events on a calendar.
Currently, I am just trying to put together a Python script which can pull some data from my own Facebook account, like a list of all my friends. I presume once I can accomplish this I can move to pulling more complicated data out of my clients account (since they have given me access to their account).
I have looked at many of the posts here, and also went through the Facebook API documentation, including Facebook Connect, but am really beating my head against the wall. Everything I have read seems like overkill, as it involves setting up a good deal of infrastructure to allow my app to set up connections to any arbitrary user's account (who authorizes me). Shouldn't it be much simpler, given I only ever need to access 1 account?
I cannot find a way to retrieve data without having to display the Facebook login window. I have a script which will retrieve all my friends, but it includes a redirect where I have to physically log myself in to Facebook.
Would appreciate any advice or links, I just feel like I must be missing something simple.
Thank you!
Just posting up my notes on the successful advice, should others find this post;
Per Daniel and William's advice, I obtained the right permissions using the Connect options. From William, this link explains how the Facebook connection works
https://developers.facebook.com/docs/authentication/
This section on setting up the actual authentication was most helpful to me.
http://developers.facebook.com/docs/api
Basically, it goes as follows:
Post a link to the following URL. A user will need to physically click on it (even if that user is just you, the site admin).
https://graph.facebook.com/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://www.example.com/HANDLER
This will redirect to a Facebook login, which will return to http://www.example.com/HANDLER after the user authenticates. If you wish to do more than basic reads and news feed updates you will need to include this variable in the above link: scope=offline_access,user_photos. The scope variable just includes a comma separated list of values, which Facebook will explicitly tell the authenticating user about during the login process, and they will have to OK. Most helpful for me was the offline_access flag (user_photos lets you get at their photos too), so I can pull content without someone logging in regularly (so long as I store the access token obtained later)
Have a script located at http://www.example.com/HANDLER that will take a variable from the request (so facebook will redirect to http://www.example.com/HANDLER&code=YOUR_CODE after authentication). Your handler needs to pull out the code variable, and then send the following request:
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_CLIENT_ID&
redirect_uri=http://www.example.com/oauth_redirect&
client_secret=YOUR_SECRET_KEY&
code=YOUR_CODE
This request will return a string of the form access_token=YOUR_ACCESS_TOKEN.
Just parse off the 'access_token=', and you will have a token that you can use to access the facebook graph API, in requests like
http://graph.facebook.com/me/friends?access_token=YOUR_ACCESS_TOKEN
This will return a JSON object containing all of your friends
Hope this saves someone else some not fun time straining through documentation. Thanks for the help!
It is true, that Facebook's API is targeted at developers who are creating apps that will be used by many users.
Thankfully, the new Graph API is much simpler to use than its predecessor, and shouldn't be terribly difficult for you to work with without using or creating a lot of underlying infrastructure.
You will need to implement authorization, but this is not difficult, and as long as you prompt the user for the offline_access permission, it'll only need to be done once.
The documentation on Desktop Authentication would probably be most relevant to you at this point, though you might want to move to the javascript-based authentication once you've got a web app up and running.
Once the authentication is done, all you're doing is making GET requests to various urls and working with the resulting JSON.
Here's the documentation about Events, and you can get a list of friends from the friends connection of a User.
I'm not expert on Facebook/Facebook Connect, however I've seen it used/used applications with it and it seems there's really only the 'official' way to do it. I'm afraid it looks like your best bet would probably be something along the lines of this.
http://wiki.developers.facebook.com/index.php/Connect/Authentication_and_Authorization
Regardless of how you actually 'use' it, you'll still need to authorize the application to connect to the account and this means having a Facebook App as well.
The answer to Facebook application authentication is hard to find but is actually found within the "Analytics" page of the Graph API.
Specify the following: https://graph.facebook.com/oauth/access_token?client_cred&client_id=yourappid&client_secret=yourappsecret , you will then be given an access_token that you may use on all other calls.
The Facebook provided APIs do NOT currently provide this level of functionality.