How to Log in With Python to Facebook
The Facebook API lets developers create remote applications that run on a local Web server but execute and interact with Facebook user data. You must log in to the Facebook API before you can run the code on the API server. The Python service uses your developer user ID and a session key provided when you signed up for the Facebook API service.
Instructions
-
-
1
Open your Python editor, and open the Facebook project you want to edit. Double-click the source code file you want to edit.
-
2
Import the Facebook API into the Python source code file. Add the following code to the top of your file:
import facebook
-
-
3
Create two variables for your "userid" and "apikey" permission requirements. The following code creates these two variables:
userid = "myusername"
key = "338du"Each of these are provided when you sign up for the Facebook API for all of your Facebook programs.
-
4
Add the Facebook API function that connects to the Facebook API and logs you in to the API service. The following code logs your app in to the service:
self.facebookapi = facebook.Facebook(userid, key)
-
1