Continuing the previous article "Detailed explanation of the main process of Sina Weibo OAuth authentication and storage", now we will Use it to tweet.
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, what you have to do now is very simple...just call the sinaOauth class to publish. .
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("测试发表微博"); 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"]);
This is the simplest one...
The above is the entire content of this article, I hope you all like it.
Please take a moment to share the article with your friends or leave a comment. We will sincerely thank you for your support!