Home > Backend Development > PHP Tutorial > 用微博获取access_token,出现21323错误

用微博获取access_token,出现21323错误

WBOY
Release: 2016-06-06 20:20:01
Original
2970 people have browsed it

问题解决了。。。我把?去掉就可以了。。

用的以下方法提交了,xxx都对应好了。不太清楚为什么返回21323。
https://api.weibo.com/oauth2/access_token?client_id=xxxxxx&client_secret=xxxxx&grant_type=authorization_code&redirect_uri=xxxxx&code=xxxxx

这个是使用的提交函数,网上用的现成的。

<code> public function https_request($url, $data = null)
  {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    if (!empty($data)){
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl);
    curl_close($curl);
    return $output;
  }</code>
Copy after login
Copy after login

回复内容:

问题解决了。。。我把?去掉就可以了。。

用的以下方法提交了,xxx都对应好了。不太清楚为什么返回21323。
https://api.weibo.com/oauth2/access_token?client_id=xxxxxx&client_secret=xxxxx&grant_type=authorization_code&redirect_uri=xxxxx&code=xxxxx

这个是使用的提交函数,网上用的现成的。

<code> public function https_request($url, $data = null)
  {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    if (!empty($data)){
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl);
    curl_close($curl);
    return $output;
  }</code>
Copy after login
Copy after login

参照微博开放平台的文档,21323表示请求不合法,是不是你没有对redirect_uri参数做编码呀
类似encodeComponent(http://myserver.com/cb)

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template