我正在使用来自http://phphttpclient.com/的 Httpful PHP 库,这是我的示例代码:
$uri = "https://ideabiz.lk/apicall/token?grant_type=password&username=user&password=pwd&scope=PRODUCTION";
$response= \Httpful\Request::post($uri)
->sendsJson()
->addHeaders(array(
'Accept' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic b28yWTJqNjJoSDN4dHdHNXVkZHhhd2RjWEhrYTp0Zlp5UU1NVEJTcGZiSGFDWFJmQTFvWTJCb2dh',
))
->send();
echo $response;
但它不返回任何东西。(这里的正文应该是空的。)我什至试过这样
$url = "https://ideabiz.lk/apicall/token";
$response = \Httpful\Request::post($url)
->sendsJson()
->authenticateWith('user', 'pwd')
->body('{
"grant_type":"password",
"scope":"PRODUCTION"
}')
->addHeaders(array(
'Accept' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic b28yWTJqNjJoSDN4dHdHNXVkZHhhd2RjWEhrYTp0Zlp5UU1NVEJTcGZiSGFDWFJmQTFvWTJCb2dh',
))
->send();
echo $response;
但是,它什么也不返回。我应该怎么办 ..?