我正在尝试使用针对OneSignal服务的api向具有特定标签的用户发送推送通知:https://www.onesignal.com/
我似乎无法正确格式化数组.这是我拥有或想要的东西,但它不起作用:
"tags" => array[{"key": "NotifyLive", "relation": "=", "value": "true"}],
Run Code Online (Sandbox Code Playgroud)
因此,我希望将标记为"NotifyLive"的用户设置为"true".
我相信这可以做到,因为它在这里的文档中显示了它.向下滚动到标签:对象数组示例.我只是无法弄清楚如何编码这一行.
以下是我通过通知发送的字段:
$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
);
Run Code Online (Sandbox Code Playgroud)
错误: 收到JSON:{"allresponses":"{\"errors \":[\"标签必须是数组.例如,[{\\"key \\":\\"gender \\",\\"relation \\":\\"= \\",\\"value \\":\\"male\\ "}] \"]}"}
该团队拥有惊人的支持,但我现在需要在工作时间之外得到答案.感谢您的任何见解.
Pap*_*eau 10
想出答案.必须以这种格式编写数组:
// 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
);
Run Code Online (Sandbox Code Playgroud)