PHP + Sina Weibo open platform + Sina Cloud Platform (SAE) development of Weibo applications-the process of establishing Weibo applications

Source: Internet
Author: User
Tags php define
1. create an application on the Weibo open platform. first, log on to your Weibo. There is a link to the open platform at the bottom of the page. click this link. Or open http://open.weibo.com/. click here to develop applications. Click Create application. As an entry-level attempt,... "> <LINKhref =" http://www.php100.com//statics/s to establish microblogging application process 1. create an application on the Weibo open platform

First, log on to your Weibo account.

There is a link "open platform" at the bottom of the page. click this link.

Or open http://open.weibo.com/. click here to develop the application ".

Click "Create application ".

As an entry-level attempt, we developed "intra-site applications ".

Follow the on-screen prompts and enter necessary information:

In "application information", select "basic information" to remember the value of the App Key and App Secret. These two values are related to authorization and need to be used in subsequent programming.

The biggest significance of creating an application is that the Weibo system allocates the App Key and App Secret values. Now, let's put down this job to prepare for coding.

 

2. download the SDK

Go to the SDK download page of the Sina Weibo open platform at http://open.weibo.com/wiki/sdk. find the php sdk download link:

Download a compressed file, as shown in.

Among these files, weibooauth. php provides code for authorizing and implementing Weibo application functions. Do not modify the content of this file.

Other files are actually demos provided for developing and running program Weibo applications ).

Decompress the compressed file and modify the code in config. php as your first weibo application.

The code in config. php is:

 

[Php]View plaincopyprint?
  1. Define ("WB_AKEY", 'Enter the APP Key of the Weibo open platform ');
  2. Define ("WB_SKEY", 'Enter the APP Secret on the Weibo open platform ');
  3. ?>
<? Php define ("WB_AKEY", 'Enter the APP Key of the Weibo open platform '); define ("WB_SKEY", 'Enter the APP Secret of the Weibo open platform');?>
Use the App Key and App Secret used to create a weibo application to rewrite this file.

 

For example, change the created application

 

[Php]View plaincopyprint?
  1. Define ("WB_AKEY", '20140901 ');
  2. Define ("WB_SKEY", 'fa9fda-1e317a942b895532b1f73837b ');
  3. ?>
<? Php define ("WB_AKEY", '000000'); define ("WB_SKEY", 'fa9f00001e317a942b895532b1f73837b');?>

 

These codes will be uploaded to the SAE cloud platform. they will be placed first. create an application in SAE and then talk about it.

 

3. create an application in SAE

Open SAE Home: http://sae.sina.com.cn/

Because you already have a Weibo account, select "log on with a Weibo account ".

The following page is displayed:

There are already two applications created by the author on the interface. If this is the first entry, the "My created applications" section is empty.

Click "Create application ".

On the "Create application" page, enter the second-level domain name, application name, and application description of sinaapp.com. Then, "create an application ".

Enter the security password. The security password is used for code deployment. you can modify it in account settings.

After clicking "security verification", the newly created application appears in "My created application.

Click the newly created application. The following figure shows the application information. Click "code management "......

Then select "create a version here "......

The version number is 1.

After you click "create", it takes some time for the system to set up the environment for running the program.

Remember the link of the application of this version. this link can be directly used and will be used as the "actual application address" of the weibo application later.

Now you need to "edit the code ".

Note the three buttons on the right of the path. Click the upload button on the rightmost side to upload the code downloaded and modified one by one in "2. download SDK.

When uploading index. php, because the file already exists, it is not allowed to be uploaded. You need to right-click the file and click "delete" from the menu to delete the original file and then upload it.

The uploaded page is as follows. open "config. php" to make sure that the App Key and App Secret are the modified values.

The success has been achieved. Find the "code management" page and click "link ".

The following page is displayed.

"Use Oauth to login" contains a very critical concept. If no table is specified here, it will be done first. then you can understand the materials again.

Then go to the "application authorization" page. In retrospect, do you need your authorization to use apps developed by others? Click "log on and authorize ".

Then, the system prompts "authorization is complete. go to your Weibo list page ".

Click the link to see the content shown in. It seems that this application is still quite functional. You can change your profile picture, send Weibo posts, and send images to Weibo posts.

So far, we have not even written a line of PHP code. As a matter of fact, we should follow this process first and establish the complete concept of the application.

So far, the result we have seen is still a Web interface of Weibo, not a weibo application. Next we will do some work to make it a real Weibo application. after that, we will simply understand the code.

 

4. make the application in SAE become a weibo application

Looking back at the application information in "1. create an application on the Weibo open platform", we recorded two important values: App Key and App Secret.

On the right side of the page, there is an "edit" link. After clicking, you can set "intra-site application address" and "actual application address ".

The "intra-site application address" requires a personalized domain name, while the "actual application address" processes the "link" in "code management" in SAE ", as shown in (as shown in the previous figure ).

Later, you can upload images and so on, not to mention. Finally, save the information.

After saving, click the link next to "intra-site application address" on the current page.

Keep following the links that appear, and you will find that this is the real Weibo application.

 

 

5. sort out the ideas

It is necessary to clarify the relationship between these links.

First, a weibo application is created on the Sina open development platform. Among them, the most important thing is to allocate the App Key and App Secret values. Weibo is a distributed system. information sharing relies on the attention of users and their peers. When running an application, the user must be identified by authentication to ensure security. These two values are very important. more principles will be applied and then read the document.

Second, an application requires code. We directly downloaded the Demo code provided in the php sdk as the business logic of our first application. In the prepared code, the App Key and App Secret are added to config. php.

Again, the application code needs to run on the Web server. We did not use the classic LAMP (Linux + Apache + Mysql + PHP) combination to use Apache as the server, but instead solved it on the Sina Cloud platform. In the cloud computing era, let the cloud serve us, and the advantages are no longer mentioned. The biggest benefit of this solution is to avoid the trouble of running environment settings, so that we can directly access the code after we upload the code, the results displayed in the Demo implement a simple application: you can change your profile picture, send Weibo posts and Weibo posts with images, and display the Weibo posts of you and the people you are interested in.

Finally, on the Weibo open platform, set "actual application address" for the link of the SAE application, and set another "intra-site application address ". The "intra-site application address" will place the application in a framework, which shows that we are used to a unified "weibo application" style.

This application is simple and has no connection to the database, no statistics and analysis, and no visual interface. However, this is a complete application. Next, we will gradually learn how to build more personalized and practical applications. In addition, an application must be submitted for review and eventually comply with some standards, which are not reflected in the Demo. please refer to the relevant documents.
 

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.