Home >Backend Development >PHP Tutorial >Publishing Weibo instances using OAuth authentication of Sina Weibo API_PHP tutorial
Continue with the previous article "Detailed explanation of the main process of Sina Weibo OAuth authentication and storage", now we will use it to post on 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, what you have to do now is very simple...just call the sinaOauth class to publish. .
The code is as follows:
?
3 4 5 67 14 15 |
//Statuses/update $c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret'] ); $msg = $c->update("Test publish on 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"]); |