How to log on with Sina Weibo account (third-party login)

Source: Internet
Author: User
I used my Sina Weibo account to log on (third-party login). I downloaded the Sina SDK package. during my test, I entered my Weibo account and password and clicked the authorize connection button. then, Sorry appears, & nbsp; that & nbsp; page & nbsp; doesn' t & nbsp; exist! How can we solve this page? Thank you ...... Log on with the Sina Weibo account (third-party logon)
I downloaded the Sina SDK package. during the test, I entered my Weibo account and password, and clicked the authorize connection button. then, Sorry, that page doesn't exist! How can we solve this page? Thank you ......
------ Solution --------------------
Use APIs in PHP to synchronize with Sina Weibo

This afternoon, I got a Sina Weibo synchronization application, tested it many times, and finally succeeded. let's talk about my configuration process. Welcome to my Sina Weibo!

First of all, have sina Weibo account, do not register a, and then be a developer, you can from the microblogging point in the past, you can also directly enter the network address: http://open.t.sina.com.cn, choose I am a developer, select Create application, enter the developer information, and then obtain your app key and app secret. copy them and save them.

Then, download the SDK document, select the PHP language, and you will see "using OAuth Authentication". I am using this. click the link below to download it and decompress it to your local computer.

Step 3: start the test. Copy the weobodemo folder in the decompressed file to the test Directory, that is, your site directory. you must configure the virtual domain name in advance. if not, refer to my other article, use apache to configure an independent virtual domain name.

The weibodemo folder contains the config. php configuration file. after opening it, you will know what to do and write your app key and app secret. Open this directory in the browser and run the index. php file automatically.

When this happens, you will find that the following error occurs: Notice: Undefined index: SCRIPT_URI in D: \ www \ weibodemo \ index. php on line 13.

Open index. php, found $ _ SERVER ['script _ URI '], $ _ SERVER parameter does not have this SCRIPT_URI at all, leave it alone, click the following link, and then an error occurs: Sorry, that page doesn' t exist!

At this point, it is estimated that many people will give up and suddenly do not know what to do. In fact, do not write Sina Weibo as an app developer. the average person can understand it. Take a closer look at index. php. the link address you just clicked is generated by the getAuthorizeURL method in the WeiboOAuth class and is related to the subsequent callback function, that is, the callback. php file.

From this, we can easily think of this process: first obtain the local configuration file config. in php, the app key and app secret must be verified to verify whether the app key is valid. In addition, we are asked if we have authorized the APP to synchronously update Weibo. if the conditions are true, we will use callback. php returns to the local device, and we can write a microblog on this callback page, and click post. after logging in to t.sina.com.cn Sina official Weibo, we can see the article message we just posted, the following should indicate "from xxx"

It is not difficult to solve this principle. Change $ _ SERVER ['script _ URI '] to our local address, that is, the address of the virtual domain name in the directory, so as to return to callback. in this way, the page cannot be found. For example: my local virtual depressing is http://localhost.com, know d:/www/this folder, my weibodemo folder is put under/www, then, I changed $ _ SERVER ['script _ url'] to http://localhost.com/weibodemo, and connected to the end of /callback.php.

In this way, you can click weobolist on your Weibo page after "authorization completed" is displayed. php, after entering, you are surprised: very rough, no style, simple html form, haha, why are Sina Weibo programmers so lazy. Send a microblog and test it. I'm so excited.

We can sum up that, in fact, it is quite simple. There are 6 files in total: config. php is the configuration file through index. php enters the Sina Weibo authentication and authorization page. after agreeing to the authorization, it returns to callback. on the php page, click my Weibo to go to the Weibo posting page and weibolist page. php, and then post Weibo, then OK. The remaining file weibooauth. php is a class file containing many classes and functions, which are previously used. if you are interested, you can study it and ignore it. Another. DS_Stor does not know anything. it is garbled and useless to open it. it is estimated that it is useless.

In addition, please pay attention to the encoding format of the page and try to debug the page with garbled characters.

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.