How to streamline Sina Weibo SDK to a file

Source: Internet
Author: User
Tags oauth
I posted an article last night about how to implement the API interface application synchronized with Sina Weibo. Some people want to associate this to their own blogs. just like me, when I post an article, a microfile is automatically generated

I posted an article last night about how to implement the API interface application synchronized with Sina Weibo. Some people want to associate this with their own blogs. just like me, when I post an article, a microblog is automatically generated. How can I skip the intermediate Authentication Authorization and directly generate and send Weibo messages? Please look down!

Configure the file, authorize it to your Weibo account, and then streamline the file.

We know that the page for sending weibo is weibolist. php. when you open it, you will find that the information you send will start? Text = xxx is forwarded, so we find the code that accepts the text. it is an if statement, which is finally transmitted using the updata method, we can copy this method to our own file.

We found that the update method used is in the new WeiboClient class, so it first contains the file where the class is located, that is, weibooauth. php, and then the new class.

At this point we doubt, can this be successful? Of course you can't. your app key and app secret haven't been written yet, but this is very simple, because the new WeiboClient class has the parameter, simply replace the constant with your app key and app secret. However, there are four parameters, followed by two: $ _ SESSION ['last _ key'] ['oauth _ token'], $ _ SESSION ['last _ key'] ['oauth _ token_secret ']. Don't worry, the value of print_r ($ _ SESSION) is a 32-bit encrypted string and copied to the corresponding location.

In this way, if the previous configuration and permission verification files are not needed, the weibooauth. php file will be retained. for example, the code I wrote will be written after the article is published:

$ Text = $ art ['title']. "-from Lu Changhong's PHP learning blog http://www.luchanghong.com/article.php? Id = {$ id }";
Include_once ('Weibo/weibooauth. php ');
$ C = new WeiboClient ('Your APP key', 'Your APP secret', '32-bit encrypted string', '32-bit encrypted string ');
$ Text = iconv ('gbk', 'utf-8', $ text); // If you use gbk encoding, convert the encoding, it is best not to change the encoding format of the source file. Otherwise, the source file is garbled.
$ Rr = $ c-> update ($ text );

OK. After you have done this, you can try to synchronize a QQ Microblog. The principle is almost the same.

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.