经过一天的研究,对原有的ThinkSDK做了BAE的兼容。
可以看到,是在bae上面登陆成功的

之所以THinkSDK不兼容BAE是由于bae的php不支持Curl扩展
取而代之的是BaeFetchUrl类
以下是简单实例
$fetch= new BaeFetchUrl();
$fetch->setHeader('Expect', '');
$fetch->setOptionMaxRedirs(2);
$fetch->setOptionFollowLocation(true);
$fetch->setCookie('timestamp', time());
$file= $fetch->get($Url);
接下来我说说,我对于原版ThinkSdk的修改 public function call($api, $param = '', $method = 'GET', $multi = false){
/* 百度调用公共参数 */
$params = array(
'access_token' => $this->Token['access_token'],
);
//$data = $this->http($this->url($api), $this->param($params, $param), $method);
$data = $this->httpbae($this->url($api), $this->param($params, $param), $method);
//此次我讲http方法替换为httpbae方法
return json_decode($data, true);
}
httpbae方法如下: /**
* 发送http请求兼容bae
* @return string
*/
protected function httpbae($url, $params, $method = 'GET'){
$BaiduUrl=$url . '?' . http_build_query($params);
$fetch= new BaeFetchUrl();
$fetch->setHeader('Expect', '');
$fetch->setOptionMaxRedirs(2);
$fetch->setOptionFollowLocation(true);
$fetch->setCookie('timestamp', time());
$data= $fetch->get($BaiduUrl);
//dump(json_decode($re));
return $data;
}
(我只兼容了百度账号登陆哦,其他思路一样)若是要在bae上实现qq,微博,人人等的登陆,也是这样改就行了
我上传的代码值改了BaiduSDK.class.php这个类
希望对大家有所帮助。有什么错误,直接给我指出吧。。