Php Sina Weibo logon interface instance code

Source: Internet
Author: User
Before logging on to Weibo, you need to apply for the APPKEY and AppSecret. to apply for this method, go to open.weibo.com to apply for relevant content. Relevant development documents are also available on the official website. weibo .... before logging on to Weibo, you need to apply for the app key and App Secret. to apply for this method, go to open.weibo.com to apply for relevant content.

Relevant development documents are also available on the official website at http://open.weibo.com/wiki.

The php sdk I downloaded here is directly used for web site applications.

Download the SDK and configure the config file.

 

* The callback address here refers to the page jump to YOUR_REGISTERED_REDIRECT_URI /? Code = CODE // YOUR_REGISTERED_REDIRECT_URI is your callback address.

The first step is to guide the user to authorize.

 GetAuthorizeURL (http: // pic3.phprm.com/2014/05/09/CANVAS_PAGE.jpg); echo "authorize";?> // Authorization address: https://api.weibo.com/oauth2/authorize?

Client_id = YOUR_CLIENT_ID & response_type = code & redirect_uri = YOUR_REGISTERED_REDIRECT_URI

If you agree to the authorization, you need to obtain the Access Token in your callback address to call the interface. Obtain information, and so on...

 getAccessToken('code', $keys);        var_dump($bb);    }?>

After obtaining the AccessToken, you can call all encapsulated functions of saetv2.ex. class. php to perform operations. for example, if I log on to the SDK, I need to obtain the user information:

 Corresponding API: users/show ** @ access public * @ param mixed $ uid_or_name UID or Weibo nickname. * @ Return array */function show_user ($ uid_or_name) {return $ this-> request_with_uid ('https: // api.t.sina.com.cn/users/show.json', $ uid_or_name);}?>

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.