public function weixinModify()
 {
     $id = intval(I('get.id'));
     if (empty($id)) {
         $this->error('访问错误');
     }
     $b = new Bridge($this->addon);
     $platform = $b->getOne($id);
     if (empty($platform)) {
         $this->error('访问错误');
     }
     if (IS_POST) {
         $rec = coll_elements(array('title', 'url', 'token', 'remark'), I('post.'));
         if (empty($rec['title']) || empty($rec['url']) || empty($rec['token'])) {
             $this->error('请填写完整后保存');
         }
         $rec = $b->table('__BR_BRIDGES__')->data($rec)->where("`id`='{$id}'")->save();
         if (!empty($rec)) {
             $this->success('保存接入平台成功', $this->U('connect/weixin'));
             exit;
         } else {
             $this->error('保存失败, 可能是因为这个平台已经接入过, 请检查 URL');
         }
     }
     $this->assign('entity', $platform);
     $this->display('weixin-form');
 }
Exemplo n.º 2
0
 public function exec($message, $processor)
 {
     if (!empty($processor)) {
         $b = new Bridge(null);
         $platform = $b->getOne($processor['id'], true);
         $body = $this->toRequestXml($message);
         $url = $platform['url'];
         if (!strpos($url, '?') == -1) {
             $url .= '?';
         } else {
             $url .= '&';
         }
         $params = array('timestamp' => TIMESTAMP, 'nonce' => util_random(10, 1));
         $signParams = array($platform['token'], $params['timestamp'], $params['nonce']);
         sort($signParams, SORT_STRING);
         $params['signature'] = sha1(implode($signParams));
         $url .= http_build_query($params, '', '&');
         $ret = Net::httpPost($url, $body);
         if (!empty($ret)) {
             return $this->toPacket($ret);
         }
     }
 }