【发布时间】:2018-09-11 22:12:43
【问题描述】:
我正在使用 bitbucket api,当我输入以下 url 时,我得到了一个访问令牌:'https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=code ' 并将我重定向到 https://api.bitbucket.org/2.0/repositories/{my-team}/?code={code} 我需要从重定向 url 中获取该 {code} 我通过以下方式使用 curl:
public function getCode()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://bitbucket.org/site/oauth2/authorize?client_id=".config('app.bitbucket_key')."&response_type=code");
$result = curl_exec($ch);
if (curl_errno($ch)) {
return 'Error: invalid credentials';
}
return $result;
}
但结果我是真的。我想在重定向 url 中获取代码查询参数。我该怎么做呢
编辑:
当我与curl_getinfo() 核对时,我发现它会将我重定向到另一个网址,即:https://bitbucket.org/account/signin/?next=/site/oauth2/authorize%3Fclient_id%3D{my_client_id} %26response_type%3Dcode
【问题讨论】:
标签: php curl bitbucket bitbucket-api