0

我想通过我的 Android 手机发送短信。我找到了一个有前途的 api 来做到这一点pushbullet

关于通过 cURL 连接到它的部分说我应该添加自定义标头Access-Token: <your_access_token_here>'。我在 php 中添加了它,但curl_exec返回false. 在 PostMan 上,我可以毫无问题地创建它。我创建 cURL 的函数如下所示:

    public function getUrlContent($url, $post)
    {
        $data_string = '{
  "push": {
    "conversation_iden": "+3 34333333",
    "message": "Hello!",
    "package_name": "com.pushbullet.android",
    "source_user_iden": "qwerqwerqwer",
    "target_device_iden": "erqwer",
    "type": "messaging_extension_reply"
  },
  "type": "push"
}';
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Access-Token: xxxxxxxxxxxxxxxxxxxx',
        'Content-Length: '.strlen($data_string), )
        );

        $result = curl_exec($ch);


        curl_close($ch);

        return $result;
    }
4

0 回答 0