我正在尝试使用 curl 生成令牌。我是 API 生成令牌的新手
<?php
$username = '12345678'; //Fill with your app username Key
$password = 'XXXXXXXXXXXXX'; // Fill with your app passowrd
$headers = ['application/x-www-form-urlencoded'];
$url = 'https://api.equitybankgroup.com/v1/token';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
$credentials = 'XXXXXXXXXXXXX'; //API Key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Basic '.$credentials));
curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
$result = curl_exec($curl);
echo $result;
curl_close($curl);
?>
我试过用邮递员发帖,效果很好。
答案 0 :(得分:1)
尝试为请求添加请求类型选项。
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars); //Post Fields