Use OAuth of Sina Weibo API to publish Weibo instance _ php instance

Source: Internet
Author: User
Tags oauth
This article describes how to use Sina Weibo API OAuth to publish Weibo instances, for more information about the OAuth authentication and storage process of Sina Weibo, see the previous article. Now we will use it to publish Weibo.

We have saved the oauth_token and oauth_secret of Sina Weibo

$ _ SESSION ['oss _ token'] = $ result ['oss _ token'];
$ _ SESSION ['oss _ secret'] = $ result ['oss _ secret'];

In this example, we need to call the sinaOauth class for release ..

The Code is as follows:

// Statuses/update $ c = new WeiboClient (WB_AKEY, WB_SKEY, $ _ SESSION ['last _ key'] ['oss _ token'], $ _ SESSION ['last _ key'] ['oss _ token_secret ']); $ msg = $ c-> update ("test posting Weibo "); if ($ msg = false | $ msg = null) {echo "Error occured"; return false ;} if (isset ($ msg ['error _ Code']) & isset ($ msg ['error']) {echo ('error _ code :'. $ msg ['error _ Code']. '; Error :'. $ msg ['error']); return false;} echo ($ msg ['id']. ":". iconv ('utf-8', 'gb2312', $ msg ['text']). "-". $ msg ["created_at"]);

In this way, the simplest thing is OK ····

The above is all the content of this article. I hope you will like it.

Please take a moment to share your article with your friends or leave a comment. Thank you for your support!

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.