dongyi4170 2017-05-04 15:42
浏览 151

cURL无法用APN倒回身体

I'm trying to send a message to an iOS device using APN, but keep getting this message:

cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I've tried disabling/enabling https, but doesn't seem to make any difference. The headers look to be exactly the same as their documentation states, but doesn't want to make any difference. Anyone have any ideas?

Here's my code:

$payload = [
        "aps" =>  [
            "alert" => "Message received from Bob"
        ]
    ];

$client = new Client();
    $response = $client->request(
        'POST',
        'https://api.development.push.apple.com:443',
        [
            'body' => \GuzzleHttp\json_encode($payload),
            'headers' =>
                [
                    'Authorization' => "Bearer: $token",
                    ':method' => 'POST',
                    ':scheme' => 'https',
                    ':path' => "/3/device/$deviceId",
                    'apns-expiration' => 0,
                    'apns-priority' => 10
                ],
            'debug' => true,
        ]
    );

Curl version info:

array (size=9)
  'version_number' => int 470272
  'age' => int 3
  'features' => int 573981
  'ssl_version_number' => int 0
  'version' => string '7.45.0' (length=6)
  'host' => string 'x86_64-apple-darwin10.8.0' (length=25)
  'ssl_version' => string 'OpenSSL/1.0.1p' (length=14)
  'libz_version' => string '1.2.8' (length=5)
  'protocols' => 
    array (size=20)
      0 => string 'dict' (length=4)
      1 => string 'file' (length=4)
      2 => string 'ftp' (length=3)
      3 => string 'ftps' (length=4)
      4 => string 'gopher' (length=6)
      5 => string 'http' (length=4)
      6 => string 'https' (length=5)
      7 => string 'imap' (length=4)
      8 => string 'imaps' (length=5)
      9 => string 'ldap' (length=4)
      10 => string 'ldaps' (length=5)
      11 => string 'pop3' (length=4)
      12 => string 'pop3s' (length=5)
      13 => string 'rtsp' (length=4)
      14 => string 'smb' (length=3)
      15 => string 'smbs' (length=4)
      16 => string 'smtp' (length=4)
      17 => string 'smtps' (length=5)
      18 => string 'telnet' (length=6)
      19 => string 'tftp' (length=4)
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题