详细信息如下: 首先,我将点击此链接,例如。 http://your.app/callback?的码 = ABC123 然后我将从url的代码变量中获得价值,然后我想将此网址重定向为 https://api.another.com/token中的POST操作 grant_type = authorization_code&安培; code = [ CODE ] url,带有代码的值
答案 0 :(得分:0)
使用卷曲:
一个例子:
<?php
// if you get the code here from the url,
$code = $_GET['code'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://api.another.com/");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"token_grant_type=authorization_code&code=" + $code);
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
?>