V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ranwu
V2EX  ›  PHP

有人用过友盟消息推送 API 吗?有个很奇怪的问题求教!

  •  
  •   ranwu · 2017-07-26 17:33:24 +08:00 · 2408 次点击
    这是一个创建于 2458 天前的主题,其中的信息可能已经有所发展或是发生改变。

    通过调用友盟消息推送 API 可以提供发送消息,查看消息状态,撤销消息等功能。在使用“查看消息状态”功能后,始终提示:

    Http code:400 details:{"ret":"FAIL","data":{"error_code":"2008"}}
    

    我知道这是 JSON 格式错误,但我可以 100%确定我的数据格式没问题。

    此代码在上午的时候可以正常查询,到了下午后就显示这个错误了,我保证此期间没有更改过代码!

    还有我想吐槽的是友盟的客服,不知道是不是专业的客服,总之他一口咬定就是我的错,而不是去确认此事,非常不爽!

    代码库:友盟推送 SDK:https://github.com/xiaolei16fan/umeng

    这份代码是我通过友盟提供的 PHP 版本的开发包来修改的。关于查询消息状态的测试代码:

    <?php
    
    namespace Notification;
    
    use PHPUnit\Framework\TestCase;
    use UmengPush\MessageStatus;
    
    /**
     * Class MessageStatusTest 消息发送状态
     * @package Notification
     */
    class MessageStatusTest extends TestCase
    {
        protected $appkey = null;
        protected $appMasterSecret = null;
        protected $timestamp = null;
        protected $taskId = null;
    
        protected function setUp()
        {
            $this->appkey = '';
            $this->appMasterSecret = '';
            $this->taskId = '';
            $this->timestamp = strval(time());
        }
    
        public function testMessageStatus()
        {
            $messageStatus = new MessageStatus();
            $messageStatus->setAppMasterSecret($this->appMasterSecret);
            $messageStatus->setPredefinedKeyValue('appkey', $this->appkey);
            $messageStatus->setPredefinedKeyValue('timestamp', $this->timestamp);
            $messageStatus->setPredefinedKeyValue('task_id', $this->taskId);
            $result = json_decode($messageStatus->send(), true);
            $this->assertEquals('SUCCESS', $result['ret']);
        }
    }
    

    这个问题已经困扰我很久了,不得已才求助大家!谢谢了!

    1 条回复    2017-07-27 09:39:24 +08:00
    luulsj
        1
    luulsj  
       2017-07-27 09:39:24 +08:00
    所以你发送的消息内容到底是什么,都不贴出来别人如何给你看什么问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5232 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 08:27 · PVG 16:27 · LAX 01:27 · JFK 04:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.