当我用Postman向push and (https://pushpad.xyz/docs/rest)的应用程序接口发出POST请求时,它会按预期工作,并且我会在桌面上收到推送通知。然而,当我手动操作时,它只显示一些损坏的HTML代码,这似乎是Pushpad的仪表板。我没有得到任何错误,我得到一个状态码200说OK。
我已经尝试过以下几种方法:
$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)有关我在postman中所做工作的更多详细信息以及我的手动代码给我的结果,请参阅图像。(参数为空)非常感谢!image
发布于 2019-03-24 01:36:59
看看页眉的节大括号。
new Client([
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Token token="for the sake of privacy removed in this question"',
'Accept' => 'application/json',
],
]);https://stackoverflow.com/questions/55315873
复制相似问题