Esempio n. 1
0
 /**
  * 服务端删除用户标签
  * @param type $paramArr
  */
 public static function deleteTag($paramArr)
 {
     $options = array('apiKey' => '', 'secretKey' => '', 'tagName' => '');
     if (is_array($paramArr)) {
         $options = array_merge($options, $paramArr);
     }
     extract($options);
     $channel = new Channel($apiKey, $secretKey);
     $ret = $channel->deleteTag($tagName);
     return $ret;
 }
Esempio n. 2
0
 function test_deleteTag($tag_name)
 {
     $apiKey = $this->apiKey;
     $secretKey = $this->secretKey;
     $channel = new Channel($apiKey, $secretKey);
     $ret = $channel->deleteTag($tag_name);
     if (false === $ret) {
         error_output('WRONG, ' . __FUNCTION__ . ' ERROR!!!!!');
         error_output('ERROR NUMBER: ' . $channel->errno());
         error_output('ERROR MESSAGE: ' . $channel->errmsg());
         error_output('REQUEST ID: ' . $channel->getRequestId());
     } else {
         right_output('SUCC, ' . __FUNCTION__ . ' OK!!!!!');
         right_output('result: ' . print_r($ret, true));
     }
 }
Esempio n. 3
0
 /**
  * 设定用户的推送时间,使用TAG来标记,默认0-24 意味着全天可接受
  * @param  string  $p_buserid 用户推送ID,百度里是buserid
  * @param bool $ispushallowed 是否接受推送
  * @param integer $pushhourstart 推送开始时间0-23
  * @param integer $pushhourend   推送结束时间1-24
  */
 public static function setTagWithPrefix($p_buserid, $p_tags = array(), $p_prefix = null)
 {
     $rets = array();
     $channel = new Channel(W2PUSH::$API_KEY, W2PUSH::$SECRET_KEY);
     if (isset($p_prefix) && strlen($p_prefix) > 0) {
         $tagsList = $channel->queryUserTags($p_buserid);
         $optional[Channel::USER_ID] = $p_buserid;
         if (is_array($tagsList) && array_key_exists('response_params', $tagsList) && array_key_exists('tags', $tagsList['response_params'])) {
             foreach ($tagsList['response_params']['tags'] as $tag) {
                 if (strpos($tag['name'], $p_prefix) === 0) {
                     $ret = $channel->deleteTag($tag['name'], $optional);
                     if (false === $ret) {
                         $rets[] = array('WRONG' => __FUNCTION__ . ' ERROR!!!!', 'ERROR NUMBER' => $channel->errno(), 'ERROR MESSAGE' => $channel->errmsg(), 'REQUEST ID' => $channel->getRequestId());
                     } else {
                         $rets[] = array('SUCC' => __FUNCTION__ . ' OK!!!!!', 'result' => print_r($ret, true));
                     }
                 }
             }
         }
     }
     $countSucc = 0;
     $countWrong = 0;
     if (isset($p_tags)) {
         $p_tags = is_array($p_tags) ? $p_tags : explode(',', $p_tags);
         foreach ($p_tags as $tarName) {
             $ret = $channel->setTag($tarName, $optional);
             if (false === $ret) {
                 $countWrong++;
                 $rets[] = array('WRONG' => __FUNCTION__ . ' ERROR!!!!', 'ERROR NUMBER' => $channel->errno(), 'ERROR MESSAGE' => $channel->errmsg(), 'REQUEST ID' => $channel->getRequestId());
             } else {
                 $countSucc++;
                 $rets[] = array('SUCC' => __FUNCTION__ . ' OK!!!!!', 'result' => print_r($ret, true));
             }
         }
     }
     return array('countSucc' => $countSucc, 'countWrong' => $countWrong, 'rets' => $rets);
 }