コード例 #1
0
ファイル: Media.php プロジェクト: supefun/SupeFramework
 /**
  * 上传媒体文件.
  *
  * @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);
 }
コード例 #2
0
ファイル: Menu.php プロジェクト: supefun/SupeFramework
 /**
  * 按菜单ID删除菜单.
  *
  * @param int $menuId
  *
  * @return bool
  */
 public function deleteById($menuId)
 {
     $this->http->post(self::API_CONDITIONAL_DELETE, array('menuid' => $menuId));
     return true;
 }
コード例 #3
0
ファイル: Staff.php プロジェクト: supefun/SupeFramework
 /**
  * 上传头像.
  *
  * @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);
 }