The easiest way to develop a Twitter-based fan platform is to migrate from there, but the Weibo fan platform has made some changes.
The following references are from: http://open.weibo.com/wiki/%E5%BE%AE%E4%BF%A1%E5%BC%80%E5%8F%91%E8%80%85%E8%BF%81%E7%A7%BB%E6%8C%87%E5%8D%97
Developer Migration Guide
If you have done public platform development before using the Weibo fan service platform, it is highly recommended to read this document to understand the details of the migration process.
Microblogging fan service interface at the beginning of the design to consider the migration of developers, so the cost of migration is not high, but the developer still need to do the following three differences to do a certain adaptation:
Difference one: When you apply for a message interface, fill in the token, Micro Bo fill Appkey
In the application of the message interface, Weibo requires developers to fill in the URL and Appkey, while the developer is required to fill in the URL and token;
Tokens are characters that are filled in by the developer, and are used only for "Verifying URL validity";
Weibo's appkey is provided by Weibo, in addition to "Verifying URL validity", and is also used to represent the developer's identity;
In the "Verify URL validity" link, the developer's Appkey Appsecret is used to generate the signature signature; in other words, the signature field encryption process for Weibo is the same as the basic, and the only difference is the token field used for encryption. Weibo is replaced with Appsecret field;
Difference Two: Access_token generation method, the validity period is different
The Access_token acquisition method is obtained by calling the corresponding interface via the AppID and Appsecret of the public number;
While the Twitter fan service interface calls the Access_token credential, is in the request message interface is the time, the verification URL succeeds, the powder clothing platform automatically returns (for example);
In addition, the Access_token voucher of the fan service interface of Weibo can also be obtained through the OAuth2.0 authorization interface of Weibo, but this is currently in development, not on line;
Regarding the validity period, the Access_token is valid for 7,200 seconds and needs to be refreshed by the developer, but the Access_token voucher of the fan service interface of Weibo is valid for one year, and the developer can re-bind or authorize the Blue v account after one year.
Therefore, we have a little change in the code of the platform, it can be used very well in Weibo.
Paste the following source code:
Valid (); Class Weibochatapi{public function valid () {$echoStr = $_get["Echostr"]; Valid signature, option if ($this->checksignature ()) {echo $echoStr; Exit }} Public Function responsemsg () {//get post data, could be due to the different environments$poststr = $GLOBALS [" Http_raw_post_data "]; Extract Post Dataif (!empty ($POSTSTR)) {$POSTOBJ = simplexml_load_string ($postStr, ' SimpleX Mlelement ', libxml_nocdata); $fromUsername = $POSTOBJ->fromusername; $toUsername = $POSTOBJ->tousername; $keyword = Trim ($postObj->content); $time = time (); $TEXTTPL = "
%s 0
%s
%s
%s
%s
"; if (!empty ($keyword)) {$msgType = "text"; $CONTENTSTR = "Welcome to Weibo world!"; $RESULTSTR = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time, $msgType, $CONTENTSTR); Echo $resultStr; }else{echo "Input something ..."; }}else {echo ""; Exit }}private function Checksignature () {$signature = $_get["signature"]; $timestamp = $_get["timestamp"]; $nonce = $_get["nonce"]; $token = SECRET; Unlike, verify with App_secret $tmparr = Array ($token, $timestamp, $nonce); sort ($TMPARR, sort_string); $tmpStr = implode ($TMPARR); $TMPSTR = SHA1 ($TMPSTR); if ($tmpStr = = $signature) {return true;} Else{return false;}}? >
The Appkey and Appsecret mentioned above can be obtained after the Http://open.weibo.com/apps registration application.
-----------------------------------------------------------------------------------------Good lunk!
http://www.bkjia.com/PHPjc/769760.html www.bkjia.com true http://www.bkjia.com/PHPjc/769760.html techarticle The easiest way to develop a Twitter -based fan platform is to migrate from there, but the Weibo fan platform has made some changes. The following references are from: Http://open.weibo.com/wiki/%E5%BE%AE%E4%BF%A ...