コード例 #1
0
ファイル: Media.php プロジェクト: nutsdo/rp-wechat
 /**
  * 上传媒体文件
  *
  * @param string $path
  * @param string $type
  * @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;
     return $response['media_id'];
 }
コード例 #2
0
ファイル: Menu.php プロジェクト: pakey/weixin
 /**
  * 按菜单ID删除菜单.
  *
  * @param int $menuId
  *
  * @return bool
  */
 public function deleteById($menuId)
 {
     $this->http->post(self::API_CONDITIONAL_DELETE, array('menuid' => $menuId));
     return true;
 }
コード例 #3
0
ファイル: Media.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 获取永久素材列表
  *
  * example:
  *
  * {
  *   "total_count": TOTAL_COUNT,
  *   "item_count": ITEM_COUNT,
  *   "item": [{
  *             "media_id": MEDIA_ID,
  *             "name": NAME,
  *             "update_time": UPDATE_TIME
  *         },
  *         //可能会有多个素材
  *   ]
  * }
  *
  * @param string $type
  * @param int    $offset
  * @param int    $count
  *
  * @return array
  */
 public function lists($type, $offset = 0, $count = 20)
 {
     $params = array('type' => $type, 'offset' => intval($offset), 'count' => min(20, $count));
     return $this->http->post(self::API_FOREVER_LIST, $params, array('json' => true));
 }
コード例 #4
0
 /**
  * 上传头像.
  *
  * @param string $email
  * @param string $path
  *
  * @return bool
  */
 public function avatar($email, $path)
 {
     $options = array('files' => array('media' => $path));
     $url = self::API_AVATAR_UPLOAD . "?kf_account={$email}";
     return $this->http->post($url, array(), $options);
 }