【问题标题】:How use "segment" in OneSignal with when POST to API?POST 到 API 时如何在 OneSignal 中使用“段”?
【发布时间】:2018-10-15 06:32:01
【问题描述】:

我正在尝试发布推送到 OneSignal 服务。我可以让它工作包括“include_player_ids”..但不能让它工作“segments

我正在尝试这个:

$data= array("app_id" => "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 
        "contents" => array("en" => "Check this!") ,
         "filters" => array("segment"=> "test"),
        "big_picture" => "http://www.xxxxx.com/img/logo2.png"
);

回复:

stdClass Object ( [errors] => Array ( [0] => Please include a case-sensitive header of Authorization: Basic with a valid REST API key. ) [reference] => Array ( [0] => https://documentation.onesignal.com/docs/accounts-and-keys#section-keys-ids ) )

也试试这个:

$data= array("app_id" => "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 
        "contents" => array("en" => "Check this!") ,
        "segments" => "all",
        "big_picture" => "http://xxxxxx.com/img/logo2.png"
);

回复:

stdClass Object ( [errors] => Array ( [0] => You must include which players, segments, or tags you wish to send this notification to. ) )

【问题讨论】:

    标签: php push-notification onesignal segment


    【解决方案1】:

    我明白了,你必须添加这样的片段:

    'included_segments' => array('test')
    

    并且要发布的 CURL 的头部必须包含 api rest key

    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
                                                   'Authorization: Basic API-REST-KEY'));
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-20
    • 2022-01-24
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多