2016-05-03 8 views
2

はこちらをご覧ください:https://www.onesignal.com/OneSignal PHPの対象タグ

私が正しく配列をフォーマットするように見えることはできません。ここで私が持っているか、何をしたいですが、それは働いていない:

"tags" => array[{"key": "NotifyLive", "relation": "=", "value": "true"}], 

だから私は「真」に設定されている「NotifyLive」のタグを持っているユーザーをターゲットにしたいです。

これはdocumentation hereに表示されているため、これが可能だと思います。 タグまでスクロールします。オブジェクトの配列の例。私はちょうどその1行をコード化する方法を理解できません。

$fields = array(
     "app_id" => "example", 
     "android_sound" => "$num", 
     "big_picture" => "http://website.com/mypic.jpg", 
     "tags" => array[{"key": "NotifyLive", "relation": "=", "value": "true"}],// Doesn't work! 
     "data" => array("autoplay" => "true"), 
     "contents" => $content, 
     "headings" => $heading 
    ); 

エラー: JSONを受け取っ:{ "allresponses": "{\" エラー\ ":[\" タグでなければなりません。ここ

は私が私の通知を送付していますフィールドがありますアレイ。たとえば、[\\ "key \\":\\ "gender \\"、\\ "relation \\":\\ "= \\"、\\ "value \\":\\ " \ "}] \"]} "}

チームには驚くほどのサポートがありますが、私は現在コーディングしているように営業時間外の回答が必要です。どんな洞察にも感謝します。

答えて

8

答えを見つけました。配列は、このフォーマットで書かなければならなかった:

// This Array format worked 
$daTags = array(
     array("key" => "NotifySound", "relation" => "=", "value" => "true"), 
    ); 

    $fields = array(
     "app_id" => "exampleID", 
     "android_sound" => "$num", 
     "big_picture" => "http://wesite.com/mypic.jpg", 
     "tags" => $daTags, 
     "data" => array("autoplay" => "true"), 
     "contents" => $content, 
     "headings" => $heading 
    ); 
0

tagsフィールドは廃止されているとして、あなたがタグ

$filters = array(
    array("field" => "tag", "key" => "NotifySound", "relation" => "=", "value" => "true"), 
); 

$fields = array(
    "app_id" => "exampleID", 
    "android_sound" => "sound", 
    "big_picture" => "http://wesite.com/mypic.jpg", 
    "filters" => $filters, 
    "data" => array("autoplay" => "true"), 
    "contents" => $content, 
    "headings" => $heading 
); 
によってユーザーをターゲットに filtersフィールドを使用する必要があります
関連する問題