邮递员请求有效,手动执行则无效。没有错误,只是不起作用
Postman Request works, doing it manually does not. No error, just doesnt work
当我向 Postman 向推送板 (https://pushpad.xyz/docs/rest_api) 的 API 发出 POST 请求时,它按预期工作并且我在桌面上收到推送通知。
但是,当我手动执行时,它只显示一些损坏的 HTML 代码,这似乎是 Pushpad 的仪表板。
我完全没有收到任何错误,我收到一个状态码 200,表示正常。
我已经尝试过以下方法:
$client = new Client([
'headers' => [ 'Content-Type' => 'application/json' ],
['Authorization' => 'Token token="for the sake of privacy removed in this question"'],
['Accept' => 'application/json'],
]);
$response = $client->post('https://pushpad.xyz/api/v1/projects/1234/notifications', [
'json' => [
['body' => 'testbody' , 'title' => 'testtitle']
]
]);
echo '<pre>' . var_export($response->getStatusCode(), true) . '</pre>';
echo '<pre>' . var_export($response->getBody()->getContents(), true) . '</pre>';
dd($response->getBody()->getContents());
我得到状态码 200
对于内容或正文,我只是得到一个简单的 '
所以问题是,为什么它在 Postman 中有效,而不是手动。
(使用 Laravel 5.5, Guzzle)
有关我在邮递员中所做的事情以及我的手动代码给我的结果的更多详细信息,请参见图片。 (参数为空)
非常感谢!
image
查看页眉部分的大括号。
new Client([
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Token token="for the sake of privacy removed in this question"',
'Accept' => 'application/json',
],
]);
当我向 Postman 向推送板 (https://pushpad.xyz/docs/rest_api) 的 API 发出 POST 请求时,它按预期工作并且我在桌面上收到推送通知。 但是,当我手动执行时,它只显示一些损坏的 HTML 代码,这似乎是 Pushpad 的仪表板。 我完全没有收到任何错误,我收到一个状态码 200,表示正常。
我已经尝试过以下方法:
$client = new Client([
'headers' => [ 'Content-Type' => 'application/json' ],
['Authorization' => 'Token token="for the sake of privacy removed in this question"'],
['Accept' => 'application/json'],
]);
$response = $client->post('https://pushpad.xyz/api/v1/projects/1234/notifications', [
'json' => [
['body' => 'testbody' , 'title' => 'testtitle']
]
]);
echo '<pre>' . var_export($response->getStatusCode(), true) . '</pre>';
echo '<pre>' . var_export($response->getBody()->getContents(), true) . '</pre>';
dd($response->getBody()->getContents());
我得到状态码 200 对于内容或正文,我只是得到一个简单的 ' 所以问题是,为什么它在 Postman 中有效,而不是手动。 (使用 Laravel 5.5, Guzzle) 有关我在邮递员中所做的事情以及我的手动代码给我的结果的更多详细信息,请参见图片。 (参数为空) 非常感谢! image
查看页眉部分的大括号。
new Client([
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Token token="for the sake of privacy removed in this question"',
'Accept' => 'application/json',
],
]);