Use OAuth of Sina Weibo API to publish Weibo instances. Use OAuth of Sina Weibo API to publish Weibo instances and continue the previous article "explanation of the main process of Sina Weibo OAuth Authentication and storage". now we will use it to publish Weibo. I use Sina Weibo API OAuth to publish Weibo instances
Continue with the previous article "details on the main process of OAuth Authentication and storage on Sina Weibo". now we will use it to publish Weibo.
We have saved the oauth_token and oauth_secret of Sina Weibo
$ _ SESSION ['Oss _ token'] = $ result ['Oss _ token'];
$ _ SESSION ['Oss _ secret'] = $ result ['Oss _ secret'];
In this example, we need to call the sinaOauth class for release ..
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'] ['auth _ token'], $ _ SESSION ['last _ key'] ['Oss _ token_secret ']); $ Msg = $ c-> update ("test posting 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"]); |
In this way, the simplest thing is OK ····
The above is all the content of this article. I hope you will like it.
Please take a moment to share your article with your friends or leave a comment. Thank you for your support!
Continue to the previous article "explanation of the main process of OAuth Authentication and storage on Sina Weibo". now we will use it to publish Weibo. I...