我想通过PHP项目上的API发送推送通知。
这是我使用的基本代码
$client = new GuzzleHttp\Client([
'base_uri' => 'https://onesignal.com/api/v1/',
'headers' => [
'Authorization'=> 'Basic '. config('onesignal.rest_api_key'),
'Content-Type' => 'application/json'
]]);
$response = $client->post('notifications', [
'form_params'=>[
'app_id' => config('onesignal.app_id'),
'included_segments' => ['All'],
'contents' => ["en"=> "Un nouveau cas de suspect vient d'être confirmé à Kinshasa"]
]]) ;当我执行它时,$response->getBody()->getContents()返回以下内容
{“错误”:“included_segments必须是字符串数组”}
我不知道Array of string是什么意思
发布于 2019-11-30 11:02:21
这个问题太愚蠢了,所以使用了其他HTTP客户端库来解决这个问题,而不是Guzzle。
我不知道为什么,但我使用了https://github.com/php-curl-class/php-curl-class,用同样的标志,我解决了我的问题!
希望它能帮到别人!
https://stackoverflow.com/questions/57650642
复制相似问题