The following describes how to use PHP to perform Tencent Weibo operations. You can also view the demo directly.
How to log on to a Weibo account using PHP
Tencent login requires two steps. The first step is to obtain the verification code based on your QQ number. The verification address is:
The code is as follows: |
Copy code |
Http://ptlogin2.qq.com/check? Uin = @ '. $ qq.' & amp; appid = 46000101
|
$ Qq represents your Weibo account. Through this verification, you can get the following results:
The code is as follows: |
Copy code |
Ptui_checkVC ('0 ','! Ccq ');
|
Here! CCQ is the corresponding verification code. This is a random code, and each access will change. Step 2: submit the user name, password, verification code, and other information to the following address:
The code is as follows: |
Copy code |
Http://ptlogin2.qq.com/login? U = @'. $ qq. '& p = '. md5 ($ password. $ verifyCode ). '& verifycode = '. $ verifyCode. '& aid = 46000101 & u1 = http % 3A % 2F % 2Ft.qq.com & h = 1 & from_ui = 1 & fp = loginerroralert
|
U = @ '. $ qq.' indicates your Weibo account.
The code is as follows: |
Copy code |
P = '. md5 ($ pwd. $ verifyCode ).' |
It is an encrypted password. This parameter is complex. First, you need to encrypt your QQ password through md5_3, then combine it with the verification code just returned, and then use md5 encryption.
The code is as follows: |
Copy code |
& Verifycode = '. $ verifyCode .' |
It is worth the verification code just returned.
The code is as follows: |
Copy code |
& Aid = 46000101 & u1 = http % 3A % 2F % 2Ft.qq.com & h = 1 & from_ui = 1 & fp = loginerroralert |
Other parameters are fixed and do not need to be modified. The following information will be returned if the address is correct after the request is made:
The code is as follows: |
Copy code |
PtuiCB ('0', '0', 'http: // t.qq.com ', '0 ');
|
At this time, even if the logon is successful, you can perform operations on Weibo.
How to use PHP to broadcast to Weibo
Sending a broadcast is very easy. You only need to specify the four parameters for sending an address (POST). The submitted address is:
The code is as follows: |
Copy code |
Http://t.qq.com/publish.php
|
POST data includes:
Conten '= urlencode ($ content) refers to the broadcast content, which must be URL encoded during submission.
Pic = & countType = & viewModel = 1. You do not need to change these parameters. Here, publish is worth noting. the php page needs to verify the submission address, the submission address must be from the http://t.qq.com/so when sending a POST request, a REFERER needs to be submitted. In this way, the release is successful, and the returned results are as follows:
The code is as follows: |
Copy code |
{Result: 0, msg: 'Broadcast successfully', info: {'tal': [{"id": "XXXXXX", "content": "u53c8u5f00u59cbu4e0bu96e8u4e86uff01 ", "time": "u521au521a", "type": 1, "image": [], "from": "XXXXXX", "name": "", "nick ": "", "pic": "", "flag": [], "count": 0, "timestamp": 1279167435}]} |
How to use PHP to listen to Weibo posts of other users
The operations for listening to Weibo are basically the same as those for sending broadcasts. They also send (POST) data to the specified address, but only two parameters are required. The submitted address is:
Http://t.qq.com/follow.php
POST data includes:
'U' => urlencode ($ follow) $ follow indicates the Weibo account of the user you want to listen.
'R' => urlencode (time () This is a random code
After submission, the returned results are as follows:
{Result: 0, msg: 'success '}
So far, the use of PHP has completed the Tencent Weibo Publishing and listening operations.