扫码登录获取用户授权的持久授权码时获取为空,打印的结果如下:
url:oapi域名/sns/get_persistent_code?access_token=608f12dcecc335daa1e948731b31479b
post_data:array(1) {
["tmp_auth_code"]=>
string(32) "2f7b09ac3e43310ca735f1da7a75ff89"
}
json_encode post_data:{"tmp_auth_code":"2f7b09ac3e43310ca735f1da7a75ff89"}
return:array(2) {
[0]=>
int(0)
[1]=>
string(0) ""
}
使用的php源码为:
$url="oapi域名/sns/get_persistent_code?access_token=".$access_token;
$post_data = array('tmp_auth_code' => $tmp_auth_code);
$object=http_post_data($url,json_encode($post_data));
echo "<br>return:";
var_dump($object);
function http_post_data($url, $data_string) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string))
);
ob_start();
curl_exec($ch);
$return_content = ob_get_contents();
ob_end_clean();
$return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return array($return_code, $return_content);
}
请问这是什么原因?post的数据看起来没问题啊,怎么没有获取到值,如果不是POST倒是会提示错误
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。