【问题标题】:onwsignal web notification erroronwsignal 网络通知错误
【发布时间】:2018-05-04 13:50:03
【问题描述】:

实际上我正在尝试从我已经获得的 url 获取数据,但我无法将数据插入到数组中请检查值是 dummy1 dummy2

Array ( [id] => 491 [headings] => ‘సౌందర్య లహరి’ ఎలా ఉంది అంటే..? [content] => శ్రీ వాసు దర్శకత్వం లో బెల... [userPic] => 682473.jpg ) JSON sent: {"app_id":"35fi6c27-5f39-4s9f-94db-79bf123g0f9","included_segments":["All"],"data":{"foo":"bar"},"contents":{"en":"dummy1"},"headings":{"en":"dummy2"},"url":"http:\/\/www.gggg.in\/view.php?id=[id]","chrome_web_image":"http:\/\/www.ggg.in\/admin\/user_images\/[userPic]"} JSON received: {"allresponses":"{\"id\":\"f66a03a4-1b17-8tf3-93ed-f3ad6rt7cdb9\",\"recipients\":6}"} 

以上数据来自url http://www.ggg.in/gistfile1.php?id=491&headings=%E2%80%98%E0%B0%B8%E0%B1%8C%E0%B0%82%E0%B0%A6%E0%B0%B0%E0%B1%8D%E0%B0%AF%20%E0%B0%B2%E0%B0%B9%E0%B0%B0%E0%B0%BF%E2%80%99%20%E0%B0%8E%E0%B0%B2%E0%B0%BE%20%E0%B0%89%E0%B0%82%E0%B0%A6%E0%B0%BF%20%E0%B0%85%E0%B0%82%E0%B0%9F%E0%B1%87..?&content=%20%E0%B0%B6%E0%B1%8D%E0%B0%B0%E0%B1%80%20%E0%B0%B5%E0%B0%BE%E0%B0%B8%E0%B1%81%20%E0%B0%A6%E0%B0%B0%E0%B1%8D%E0%B0%B6%E0%B0%95%E0%B0%A4%E0%B1%8D%E0%B0%B5%E0%B0%82%20%E0%B0%B2%E0%B1%8B%20%E0%B0%AC%E0%B1%86%E0%B0%B2...&userPic=682473.jpg

我需要在这个函数中插入值

function sendMessage() {
$content      = array(
    "en" => 'dummy1'
);
$headings   = array(
    "en" => 'dummy2'
);
$hashes_array = array();

$fields = array(
    'app_id' => "35fi6c27-5f39-4s9f-94db-79bf123g0f9",
    'included_segments' => array(
        'All'
    ),
    'data' => array(
        "foo" => "bar"
    ),
    'contents' => $content,
    'headings' => $headings,
    'url' => 'http://www.gggg.in/view.php?id=[id]',
    'chrome_web_image'  => 'http://www.ggg.in/admin/user_images/[userPic]',        

);

【问题讨论】:

    标签: php html url push-notification onesignal


    【解决方案1】:

    OneSignal 不支持将变量数据直接替换为 API 调用。但是,您可以使用标记和变量替换来实现此目的:https://documentation.onesignal.com/docs/personalization

    【讨论】:

    • 正如您所说,OneSignal 不支持将变量数据直接替换为 API 调用。那是错误的,只是我没有这样做
    【解决方案2】:

    这是我问的这个问题的解决方案 实际上我有一个通过 url 的变量,我需要它们插入到函数中

    $array = [
    'id' => 498, 
    'value2' => 'యూట్యూబ్‌లో “భరత్ అనే నేను” అన్ కట్ సీన్లు..!',
    'value1' => 'కొరటాల శివ దర్శకత్వం లో సూ...',
    'value3' => '525722.jpg'
    ];
    
    
    sendMessage($array);
    
    function sendMessage($array) {
        $content      = array(
            "en" => $array['value1']
            );
        $headings   = array(
            "en" => $array['value2']
            );
        $hashes_array = array();
    
    
    $fields = array(
        'app_id' => "31pe2347-5i39-4y9f-2222-79b5875f00f9",
        'included_segments' => array(
            'All'
            ),
        'data' => array(
            "foo" => "bar"
            ),
        'contents' => $content,
        'headings' => $headings,
        'url' => 'http://w...content-available-to-author-only...9.in/view.php?id=' . $array['id'],
        'chrome_web_image'  => 'http://w...content-available-to-author-only...9.in/admin/user_images/' . $array['value3'],        
    
        );
    print_r($fields);
    

    }

    【讨论】:

      猜你喜欢
      • 2019-05-03
      • 1970-01-01
      • 1970-01-01
      • 2018-01-13
      • 1970-01-01
      • 2019-12-03
      • 2019-05-13
      相关资源
      最近更新 更多