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