请教关于百度云推送的问题(急)

WBOY
Release: 2016-06-23 13:25:28
Original
1222 people have browsed it

最近在做百度云推送接口的问题,出现了些问题
代码如下:

//推送ios设备消息     function test_pushMessage_ios ($user_id,$channel_id,$title,$badge,$receivemobile,$caseid,$msgid)    {        $appid    = $this->appid;        $apiKey   = $this->apiKey;        $secretKey= $this->secretKey;         //$this->initPUSH();        $channel = new Channel ( $apiKey, $secretKey ) ;                /*  $push_type         * 1:单个人,必须指定user_id 和 channel_id (指定设备上的指定用户)或者user_id(指定用户的所有设备) * 2:一群人,必须指定 tag_name  * 3:所有人,无须指定tag_name、user_id、channel_id             */             $push_type = 1; //推送单播消息              $optional[Channel::USER_ID] = $user_id; //如果推送单播消息,需要指定user         // $optional[Channel::CHANNEL_ID] = $channel_id ; //如果推送单播消息,需要指定user             $optional[Channel::DEVICE_TYPE] = 4;//指定发到ios设备        $optional[Channel::MESSAGE_TYPE] = 1; //指定消息类型为通知        //如果ios应用当前部署状态为开发状态,指定DEPLOY_STATUS为1,默认是生产状态,值为2.     旧版本曾采用不同的域名区分部署状态,仍然支持。        $optional[Channel::DEPLOY_STATUS] = 2;        //通知类型的内容必须按指定内容发送,示例如下:               $message = '{                		"aps":{                			"alert":"'.$title.'",                			"sound":"",                			"badge":'.$badge.'                                           		},                        "receivemobile":"'.$receivemobile.'",                        "caseid":"'.$caseid.'",                        "msgid":"'.$msgid.'"                                                                  	}';        $message_key = "msg_key";        $ret = $channel->pushMessage ( $push_type, $message, $message_key, $optional ) ;        //return $ret;        if ( false === $ret )        {            $this->error_output ( 'WRONG, ' . __FUNCTION__ . ' ERROR!!!!!' ) ;            $this->error_output ( 'ERROR NUMBER: ' . $channel->errno ( ) ) ;            $this->error_output ( 'ERROR MESSAGE: ' . $channel->errmsg ( ) ) ;            $this->error_output ( 'REQUEST ID: ' . $channel->getRequestId ( ) );        }        else        {            $this->right_output ( 'SUCC, ' . __FUNCTION__ . ' OK!!!!!' ) ;            $this->right_output ( 'result: ' . print_r ( $ret, true ) ) ;        }
Copy after login

1、之前在开发状态下,单播消息推送一直是正常的,没有任何问题,但是切换到生产状态下,推送一直失败;
2、咨询了一些人,说需要初始化证书,所以在 $channel = new Channel ( $apiKey, $secretKey ) ;之后加入了正式初始化的程序(如下程序),推送单播消息还是失败;但是这里出现了个问题是,我切换到开发状态下,单播也失败了,只有群推可以成功;
3、在百度管理控制台里,原来群推还可以收到消息,现在在管理控制台不是是开发状态还是生产状态,群推都收不到消息。

请各位帮我检查检查,看问题出现在了哪儿。

$devcert="/opt/lampp/htdocs/baidu/MessageCent.pem";        $discert="/opt/lampp/htdocs/baidu/MessageCent2.pem";                $cert_name="test";        $cert_des="test";        $cert_name="test";        $cert_des="test";                                $fd = fopen($devcert, 'r');        $devcert = fread($fd, filesize($devcert)); // 开发版APNs pem证书                $fd = fopen($discert, 'r');        $discert = fread($fd, filesize($discert)); // 发布版APNs pem证书        //print_r($discert);                $ret = $channel->initAppIoscert($cert_name, $cert_des, $discert, $devcert); // cert_name和cert_des您自定义字符串即可
Copy after login


回复讨论(解决方案)

生产环节下,推送单播消息,提示
[1;40;32mSUCC, test_pushMessage_ios OK!!!!![0m [1;40;32mresult: Array ( [request_id] => 2197319330 [response_params] => Array ( [success_amount] => 0 [msgids] => Array ( ) ) ) [0m
如果生产模式下,群推,提示
[1;40;32mSUCC, test_pushMessage_ios OK!!!!![0m [1;40;32mresult: Array ( [request_id] => 2196426378 [response_params] => Array ( [success_amount] => 1 [resource_ids] => Array ( [0] => msgid#5305396010453184756 ) ) ) [0m 

楼主解决了吗?告知一下,谢谢!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template