![](/img/trans.png)
[英]Guzzle: Call to undefined method GuzzleHttp\\\\Psr7\\\\Stream::getStatusCode()
[英]guzzle undefined function getStatusCode()
我的代碼如下:
require_once $DOCUMENT_ROOT.'/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
...
if($token!='' && $email!='')
{
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://graph.microsoft.com/v1.0/me/sendmail', [
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/json;odata.metadata=minimal;odata.streaming=true'
],
'body' => $email
]);
if($response.getStatusCode() === 201) {
exit('<h1>Email sent, check your inbox</h1>');
} else {
exit('<h2>There was an error sending the email.</h2> Status code: ' . $response.getStatusCode());
}
}
我不斷收到錯誤消息, 調用未定義的函數getStatusCode() 。 我知道我需要添加其他用途,但是我已經嘗試了所有方法,但無法正常工作,每次都出現相同的錯誤。
修復。 從Microsoft復制了代碼,應該是:
if($response->getStatusCode() === 202)
也是202不是201成功
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.