簡體   English   中英

Guzzle \\ Post有效,但是使用createRequest時,我會得到null

[英]Guzzle\Post works, but with createRequest I get null

所以這工作:

$request = $this->client->post($this->getRequestPath(), [
    "body" => [
        "grant_type"        => "client_credentials",
        "client_id"         =>  $this->config['client_id'],
        "client_secret" =>  $this->config['client_secret'],
        "scope"                 =>  $this->config['scope'],
    ],
    "debug" => true
]);

但是,這不起作用

$request = $client->createRequest($type, $this->getRequestPath(), ['body' => $parameters, "debug" => true] );
$client->send($request);

我想使用createRequest因為如您所見,我希望在發送的請求類型上保持靈活性。

任何想法為什么它不起作用? 我確實獲得了調試報告,而且看起來還不錯,我還獲得了null作為返回值,並且我認為主體與post方法的傳輸方式有所不同,這就是為什么我的api無法正確識別它的原因。

我感謝您的幫助。

好的,它確實像這樣工作,唯一的事情是,獲取請求需要“查詢”而不是“正文”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM