Getting Started with Facebook APIs

Source: Internet
Author: User
Tags oauth

Facebook Business Value Profile

Facebook is a social networking service website, launched on February 4, 2004, and Facebook is overtaking Yahoo as the world's third-largest website by February 2, 2010, with Microsoft's top three. The number of new users added to Facebook in the one months is equivalent to the number of users that Yahoo has increased in a year, with a current registered user of 350 million, half of whom visit the site every day. In the face of such a large and active user community, the enterprise has seen the huge business opportunities it contains. Many brands have created corporate accounts on Facebook, collecting feedback on product reviews, and making adjustments to their products and brands in a timely manner to seize market opportunities. At present, there are many excellent intelligent analysis tools on the market, which can analyze the information of various media on the network, analyze the user's preferences and potential purchase behavior through data mining technology.

About Facebook API

The most common way to get Facebook's data is through a Web page, with Coca-Cola as an example, where users can log on to Http://www.facebook.com/cocacola to get a variety of data from the page, including user reviews of the product, product albums, and so on. Facebook's front-end interface is very friendly, with a lot of the latest UI technology to bring a better user experience. Similar front-end display Technology Service objects are people, and the program in the processing of unstructured data, there are many difficulties, with the front page layout of the continuous updating, only the use of web crawler can hardly guarantee the accuracy of crawling information

Facebook launched a Facebook API platform, called the Graph API, to solve the problem of accessing data from third-party programs. It allows ordinary users to read and write to various objects on Facebook social Graph, the API is designed to be very simple, developers do not need to spend a lot of time to read the document, in the shortest possible time to get started.

Facebook API Development Getting Started restful method get data

Take Coca-Cola's Facebook example, if we want to get other users to comment on their graffiti wall (Wall), all we have to do is type in the browser: Https://graph.facebook.com/cocacola/feed, The system will return the results in a JSON array format. JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy to read and write, and is easy for machine parsing and generation.

Figure 2. Get comments from other users on their graffiti wall (Wall)

The data contains the message ID, message content, author, author id, publication time, and various other messages. Not only the graffiti wall (Wall), all the Facebook objects can be accessed using the following URL structure: Https://graph.facebook.com/ID/CONNECTION_TYPE, the following table lists some common objects.

facebook Object access Method
buddy list (Friends) /td> https://graph.facebook.com/{id}/friends
News Feed HTTPS://GRAPH.FA Cebook.com/{id}/home
user Preferences (likes) https://graph.facebook.com/{id}/likes
Movie (Movies) https://graph.facebook.com/{id}/movies
Books (Books) https://graph.facebook.com/{id}/books
Album (photo Albums) https://graph.facebook.com/{id}/albums
Uploading videos (video uploads) https://graph.facebook.com/{id}/videos/uploaded
Group (Groups) https://graph.facebook.com/{id}/groups

Only the object is public and can be accessed directly from the above method, and if it is private, access token access needs to be provided, the following sections of the article are described in the corresponding sections.

Facebook API Development Advanced use access token to visit graffiti wall

In the example above, the Coca-Cola Company Graffiti Wall (Wall) We visited is the property of public and everyone can view the above content without any authentication. However, most of the personal account wall properties are private and need to provide the correct token to access.

The Facebook Graph API uses OAuth 2.0 as a privilege control, a simplified version of OAuth that leverages the SSL protocol as the API for communication, rather than complex URL signing and token swapping. The way to use access tokens is particularly simple, if you want to see your friends list, the URL is as follows: Https://graph.facebook.com/me/friends?access_token=XXXX

Me is the keyword in the argument, which represents my ID, and if you want to access someone else's wall of graffiti, you should use the ID to uniquely identify a user. The Access token parameter is followed by a system-random string.

Get ID and access token

The previous overview of how to access the private graffiti wall using access token describes a way to get IDs and access tokens.

When you first log in to your Facebook account, move your mouse to the avatar location, and the URL below the browser contains a unique ID for that account.

Authorizing a user

Facebook Platform provides support for OAuth 2.0 authentication and an older, customized authorization signature scheme. You should avoid using older authentication schemes when writing new applications, because support for this old scheme will soon be canceled. For more information about OAuth, see the OAuth 2.0 Protocol specification in resources.

Facebook SDK for Android, together with Facebook Platform, hides the complexities of OAuth identity authentication, as shown in figure

OAuth 2.0 Protocol (IETF)

Getting Started with Facebook APIs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.