Firebase云消息传递使用大图像php发送消息

时间:2018-07-16 14:23:54

标签: php firebase-cloud-messaging

我不知道如何附加大图像来推送消息。我已经看到其他推送服务可以做到这一点。我使用以下代码发送推送通知。

        $url = 'https://fcm.googleapis.com/fcm/send';
        $YOUR_API_KEY = '#API-key-here#'; // Server key
        $YOUR_TOKEN_ID = $token;

        $request_body = array (
            'to' => $YOUR_TOKEN_ID,
            'notification' => array (
                'title' => $message["title"],
                'body' => $message["body"],
                'icon' => $message["icon"],
                'click_action' => $message["url"]
            ),
        );
        //print_r($request_body);
        //exit;
        $fields = json_encode($request_body);
        $request_headers = array (
            'Content-Type: application/json',
            'Authorization: key=' . $YOUR_API_KEY,
        );

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
        curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        $response = curl_exec($ch);
        curl_close($ch);

谢谢

0 个答案:

没有答案