Пример #1
0
 /**
  * 获取用户列表.
  *
  * @param int $offset
  * @param int $limit
  *
  * @return Supe\Wechat\Utils\Bag
  */
 public function lists($offset = 0, $limit = 10)
 {
     $params = array('begin' => $offset, 'limit' => $limit);
     $stores = $this->http->jsonPost(self::API_LIST, $params);
     return Arr::fetch($stores['business_list'], 'base_info');
 }
Пример #2
0
 /**
  * 上传媒体文件.
  *
  * @param string $type
  * @param string $path
  * @param array  $params
  *
  * @return string
  */
 protected function upload($type, $path, $params = array())
 {
     if (!file_exists($path) || !is_readable($path)) {
         throw new Exception("文件不存在或不可读 '{$path}'");
     }
     if (!in_array($type, $this->allowTypes, true)) {
         throw new Exception("错误的媒体类型 '{$type}'");
     }
     $queries = array('type' => $type);
     $options = array('files' => array('media' => $path));
     $url = $this->getUrl($type, $queries);
     $response = $this->http->post($url, $params, $options);
     $this->forever = false;
     if ($type == 'image') {
         return $response;
     }
     $response = Arr::only($response, array('media_id', 'thumb_media_id'));
     return array_pop($response);
 }
Пример #3
0
 /**
  * Remove item form Bag.
  *
  * @param string $key
  */
 public function forget($key)
 {
     Arr::forget($this->data, $key);
 }
Пример #4
0
 /**
  * 生成 js添加到卡包 需要的 card_list 项.
  *
  * @param string $cardId
  * @param array  $extension
  *
  * @return string
  */
 public function attachExtension($cardId, array $extension = array())
 {
     $timestamp = time();
     $ext = array('code' => Arr::get($extension, 'code'), 'openid' => Arr::get($extension, 'openid', Arr::get($extension, 'open_id')), 'timestamp' => $timestamp, 'outer_id' => Arr::get($extension, 'outer_id'), 'balance' => Arr::get($extension, 'balance'));
     $ext['signature'] = $this->getSignature($this->getTicket(), $timestamp, $cardId, $ext['code'], $ext['openid'], $ext['balance']);
     return array('cardId' => $cardId, 'cardExt' => JSON::encode($ext));
 }