Getting started with Facebook app PHP Development

Source: Internet
Author: User
Foreword Laomei has been leading the technology trend. let's talk about openness. from Google to Facebook and then to Twitter, the three companies have a great deal of fun with open APIs. If it is not open, it is estimated that Facebook and Twitter will not rise in such a short period of time, so that Google and Microsoft will not be able to fight back. If you look at "> <LINKhref =" ht

Preface

Laomei has been leading the technology trend. let's talk about openness. from Google to Facebook and then to Twitter, the three companies have a great deal of fun with open APIs. If it is not open, it is estimated that Facebook and Twitter will not rise in such a short period of time, so that Google and Microsoft will not be able to fight back.

From a programmer's perspective, Facebook's core tables are only 45, but they seem simple and do not affect the power of others. for example, Wordpress tables are rarely used. During this period of time, Facebook's App development was involved. there were very few materials in China, mainly because Facebook was not accessible in China, so there were very few people doing Facebook development and there were naturally fewer materials.

Knowledge preparation

If you want to develop Facebook apps, the first thing you need to do is to go over the wall. because Facebook is in the middle of the road, don't ask me why, you know. Then you still need some basic English skills. although Facebook has simple Chinese characters, many things are still in English for developers, but it doesn't matter. it's actually very simple, it can be done in English that I am so mentally retarded.

In fact, Facebook supports a variety of development languages, including C #, Python, Javascript, Java, and so on. Javascript/PHP/Python and Android and iPhone have official SDKs. Therefore, if you have development experience in one of the above languages, you can develop apps. In fact, I personally think that the most important thing is creativity + Html/CSS/Javascript. Development based on third-party platforms is generally not a very powerful application, but after all, 0.2 billion of the users are not built, and you are scared to death by picking up a fraction of the users.

OK. To sum up, you need one of the development experiences of C #/Java/Python/Javascript. The official recommendation is PHP5, which is actually not too difficult. The most important thing is the basic web page language, which is simple but practical. In addition, you may need some simple SQL statements, which are not too difficult.

Application

Apply for a Facebook account. if you already have an account, skip this step.

Apply to activate the Developer permission. the actual Developer function is also put on Facebook as a special App. you can click here. it seems that I have not found the portal. just click agree.

Click the Set Up New Application button. at this time, Facebook will ask you to use a credit card or mobile phone to verify your identity.

  

 

Enter the basic information of the program. this is the name of your App. Then follow the prompts to proceed step by step. I will not describe it here. Tips: the program name can be the same as that of others, but the Canvas Page cannot conflict. In fact, the Facebook program uses the http://developer.facebook.com/canvaspage/method to compile. Therefore, the Canvas Page must be globally unique, basically, all the names you can think of have been applied. Canvas URL is the address on your server, because Facebook supports iFrame integration.

Here you can obtain an Application Key, App ID, and Application Secret. The App Key and App ID are usually used for verification during development. For more complex settings, let's ignore them for the moment, but there is a Sandbox Mode in Advanced that can be selected as Enable, because you can put the program into the Sandbox during development, no need to be seen by others.

Demo

The APIs provided by Facebook can be said to be very powerful. At present, I have not used human networks and 51 APIs, and I do not know what their APIs are like. Facebook APIs can directly write SQL statements. of course, this SQL statement will undergo security review. Before writing a Demo, I will briefly introduce the composition of FacebookAPI.

Facebook APIs are mainly composed of four parts: FQL/FBML/Graph API/Social plugins. among them, Social plugins mainly provides tools for third-party websites, such as OpenID login and Like buttons. FBML is a variant of xHTML. if you use iFrame, you can ignore their markup language and directly write it on your own. So I will not talk about these two APIs for the moment. I will mainly talk about FQL and FBML.

FQL is actually an SQL statement provided by Facebook. you can use FQL to query 45 Facebook tables. it is basically no different from general SQL statements, but does not support join queries, in query is supported, which is probably the case according to my test.

It should be noted that the content you query must be in the authorized state. it does not mean that you can obtain the information of all users by giving an SQL statement. FQL does not allow * to query all fields. you must directly write the field name. For more information about FQL, visit here.

Speaking of authorization, I have also found a lot of information for this matter. by default, many materials such as users' E-mail are null. Later, I discovered that I needed to go through the Authorization Application. the official website provided a lot of authorization instructions. interested friends can visit here. In Javascript, authorization is performed by adding authorization parameters to FB. login. Other development languages are also similar.

For Graph APIs, we can understand the refined version of FQL, because many times we only need simple applications and do not need to directly query SQL statements, such as getting friends from users, you can directly use my/friends to get user activities and use me/events directly. We can understand Graph API in this way. Facebook gives all content a unique encoding, whether it is activity or image, application, or user profile, the Graph API can access these materials through this unique encoding. For more information about Graph API, visit here.

Finally, let's bring up the Demo code for the last big meal. I used Javascript for this Demo. you can choose a development language that you are familiar. Here is another Tips. if you select the iFrame method instead of FBML, you can deploy the program to your local machine and modify the Hosts file, if you direct the DNS of your program to a local computer, it will be OK. the advantage is that you do not need to upload the DNS to the server every time you modify it.

  


Hello World







 

 

Http://developers.facebook.com/docs/reference/javascript/

Http://developers.facebook.com/

Reference Resources: Facebook Developer Center Javascript sdkphp sdk Python SDK

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.