Thursday, 11 September 2014

Facebook APIs :

There are two types of API :

1. Ads API
2. Graph API

1) Ads API :





Facebook's marketing API allows you to create and access your ads programmatically. You can use the Ads API to build tools that add value to customers on top of facebook's Ads manager.You can use the Ads API to build tools that add value on top of facebook's Ads manager and Power editor.


-> Ads API Structure:

An app is required to begin using the Ads API. Since the Ads API is build on the Graph API, It is recommended to review the Graph API, an introduction to objects on the social graph, e.g. User and connection between the objects, e.g. friend relationships.

The Ad API is made up of various objects, and each objects has connections to other objects. For example, an Ad account is an object and a connection is the relationship between an account and the campaigns within the account.
 


Various Ads API object:




Business Manager - It is an entity which owns all Facebook assets.

Ad user - It is a regular Facebook user who chooses to create Ads.
 

Ad Account - It is an Account Object for managing ads.

Ad Account Group - A group for managing access to Facebook ad accounts.

Ad Campaign - A campaign for managing ad sets. 

Ad Sets - Ad set for managing ad groups.

Ad Group - An Ad Group contains the data necessary for an ad.

Ad Creative - this object contains information render the look of ad.

Ad image - Images for use in ads.

Connection Object - These objects are the Facebook objects which the ad user is associated with.



 2) Graph API :




The Primary way for apps to read and write to the Facebook social graph. The Graph API has multiple versions available. It's a low level HTTP - based API that you can use to query data, post new stories, upload new photos and a variety of other tasks that an app might need to do. 


All nodes and edges in the Graph API can be read simply with HTTP Get request to the relevant endpoint. It is a powerful resource which can be used in a massive variety of ways. 


-> Common Scenarios for using the Graph API
  
1. You can determine whether two people are friends on Facebook, without having to parse their entire list of friends using this API:

/ {user-a-id}/friends/ {user-b-id}

2. Although you can't get a list of all the fans of Facebook Page, you can find out whether a specific person has liked a page using this API:

/ {user-id}/likes/ {page-id}
  
3. Apps are able to publish and create new photo albums, and publish photos via the graph API on behalf of people or Facebook pages. Photos can be uploaded by sending the actual image files. or by using URL of images already on the internet using these APIs:
  
/ {user-id}/albums - empty album creation for people on facebook.

/ {user-id}/photos - upload photosfor people on facebook.

/ {page-id}/albums - empty album creation for facebook pages.

/ {page-id}/photos - upload photos for facebook pages.

/ {album-id}/photos - to upload photos into the existing album.

 
4. Apps can share links to content on other websites on behalf of people or pages using these APIs:


/ {user-id}/feed - for people on facebook using the link field.

/ {page-id}/feed - for pages on facebook using the link field.

5. Using this API it is also possible to back-date page posts with the help of Graph API. This can involve updating and existing post with a new date, or creating it at publish time in following way:


/ {page-id}/feed to publish Pages posts, using the backdated time field. 











Reference : www.developers.facebook.com