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:
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!