Home > Backend Development > PHP Tutorial > Use the OAuth authentication of Sina Weibo API to publish Weibo instances, apioauth_PHP tutorial

Use the OAuth authentication of Sina Weibo API to publish Weibo instances, apioauth_PHP tutorial

WBOY
Release: 2016-07-13 10:00:11
Original
864 people have browsed it

Use the OAuth authentication of Sina Weibo API to publish Weibo instances, apioauth

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

Copy after login

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!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/974658.htmlTechArticlePublish Weibo instances using OAuth authentication of Sina Weibo API, apioauth Continue with the previous article "Sina Weibo OAuth Authentication "Detailed explanation of the main process of storage and storage", now we use it to publish micro...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template