卷曲反应是无法理解的

时间:2019-05-29 11:06:23

标签: laravel api curl oauth-2.0 mailchimp

当我发送curl请求以获取access_token时,响应或结果是人类无法理解的

当我通过身份验证后,我的重定向网址就会转移到list()

public function list()
{
      $url = 'https://login.mailchimp.com/oauth2/token';
      $data = [
        'grant_type' => 'authorization_code',
        'client_id' => 2xxxxx177380,
        'client_secret' => '4b02xxxx21dcd32d5406a7d',
        'redirect_uri' => 'http://127.0.0.1:8000/success',
        'code' => $_GET['code']
        ];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $response = curl_exec ($ch);
     $err = curl_error($ch);  //if you need
     curl_close ($ch);
     return $response;
    }

这是我得到的结果,其中重定向链接为:http://127.0.0.1:8000/list?access_token=9be9d4b1d724a0b19c7f4aff677b2b69&expires_in=0响应:

VJ- *�/R�R��+K��L�/ J-,M-.Q��6�

1 个答案:

答案 0 :(得分:0)

这有什么改变吗?

curl_setopt($ch, CURLOPT_HTTPHEADER, 'text/plain;charset=UTF-8');
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');