Skip to main content

Added the DELETE method

Project description

fb is a python sdk for the Facebook Graph Api. The sdk provides three methods
for interacting largely with facebook. publish(), get_object() and delete()

sudo pip install fb

1. Publishing to Facebook

For publishing, use the publish() method. Publishing means creating objects like:
a wall post, a like, events and albums, etc. Currently photo upload
is not supported. The method returns the id of the object created.
under ‘Other Objects’, see list of publish categories except “photos”.

Examples

import fb
# Go to developers.facebook.com/tools/explorer to generate test token
token=”the facebook token you are going to use
facebook=fb.graph.api(token)

#Post on the current user’s wall
facebook.publish(cat=”feed”, id=”me”, message=”My facebook status”)

#Like an object(wall post, photo and anything thats likable in facebook) with id=object_id
facebook.publish(cat=”likes”, id=object_id)

#Comment on an objects thats commentable
facebook.publish(cat=”comments”, id=object_id, message=”My comment”)

#Create an album
facebook.publish(cat=”albums”, id=”me”, name=”Album Name”, message=”Album Details”)

Create an event
facebook.publish(cat=”events”, id=”me”, name=”My Event”, start_time=”2013-10-16-12:20”, end_time=”2013-10-18-14:30” )

Important

In addition to ‘cat’ (the category) and ‘id’, publish takes any parameter thats
valid for the publish category(cat). Like “message” for wall post, “name” for albums,
nothing for likes, etc. Check facebook doc for full list of valid parameters
for each kind of publishing. If you find that a parameter is raising error,
it maybe because this sdk does not yet support the parameter,please report such cases
to the author.

2. Fetch Objects from Facebook

Objects can be fetched in two ways using the get_object() method.
Fetch “single” object with it’s given “fields” passed in a list.
Or retrieve “multiple” objects passed with their “ids” in a list.
The method returns the object as python dictionary containing related fields

Examples

#Retrieve given fields for a single object
object=facebook.get_object(cat=”single”, id=object_id, fields=[“name”, “email” ] )

#Retrieve ALL fields for a single object
object=facebook.get_object(cat=”single”, id=object_id, fields=[ ] )

#Rertieve multiple objects
object=facebook.get_object(cat=”multiple”, ids=[‘zuck’, ‘me’] )

3. Delete Objects

Deleting objects is simple. use the delete method and pass the id of the
object to be deleted. Note that a “like” has no id in facebook, so in case of deleting
a “LIKE”, you have to pass the id of the object liked and the category of the delete
which is “likes”.

Examples

#Delete a status
facebook.delete(id=status_id)

#Delete a comment
facebook.delete(id=comment_id)

#Delete a “LIKE”
#facebook.delete(cat=”likes”, id=object_id)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fb-0.2.0.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file fb-0.2.0.tar.gz.

File metadata

  • Download URL: fb-0.2.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4a65a1bcdf82cd9b312b032e5639905e69b386a36d578c0f21f2cebb390a9e45
MD5 dab4487711f6e18536f08956bb18234f
BLAKE2b-256 10ca2ffbdcaeda1da944346c753b4a5f277c2af5de47295c0b881091ed79a2e0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page