Use the Sina Weibo API's OAuth authentication to publish a microblog instance _php tutorial

Source: Internet
Author: User
Tags oauth

Use the Sina Weibo API's OAuth authentication to publish an instance of Weibo


Continue with the previous article "The main process of Sina Weibo OAuth authentication and storage", and now we use it to publish Weibo.

We have saved the Oauth_token and Oauth_secret of user Sina Weibo to

$_session[' Oauth_token ']= $result [' Oauth_token '];
$_session[' Oauth_secret ']= $result [' Oauth_secret '];

Inside, it's easy to do now. is to call the Sinaoauth class for publishing.

The code is as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

Statuses/update

$c = new Weiboclient (Wb_akey,

Wb_skey,

$_session[' Last_key ' [' Oauth_token '],

$_session[' Last_key ' [' Oauth_token_secret ']);

$msg = $c->update ("Test published micro-blog");

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"]);

So the simplest is OK.

The above mentioned is the whole content of this article, I hope you can like.

Please take a moment to share the article with your friends or leave a comment. We would be grateful for your support!

http://www.bkjia.com/PHPjc/975132.html www.bkjia.com true http://www.bkjia.com/PHPjc/975132.html techarticle use the Sina Weibo API's OAuth authentication to publish a microblog instance to continue with the previous article "Sina Weibo OAuth authentication and storage of the main process details", now we use it to publish Weibo. I ...

  • 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.