Use OAuth of Sina Weibo API to publish Weibo instance _ PHP Tutorial

Source: Internet
Author: User
Tags oauth
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.