Created
December 10, 2015 07:54
-
-
Save sursir/85696114b834294f7e7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PictureTaobaoModel extends TaobaoModel | |
{ | |
/** 初始化方法 */ | |
protected function _initialize() | |
{} | |
/** | |
* 功能:检测用户图片空间是否有指定的图片分类 | |
* @param session 用户session | |
* @param title 用户图片空间类目名称 | |
* @return 分类id | |
*/ | |
public function getPictureCatetoryByName($name) | |
{ | |
$this->setMethod('taobao.picture.category.get'); | |
$this->setParam('picture_category_name',$name); | |
$res = $this->execute(); | |
$data = $res; | |
if (! isset($res['error_response'])) | |
$data = $res['picture_category_get_response']['picture_categories']['picture_category']; | |
return $data; | |
} | |
/** | |
* 添加图片分类 | |
* @param string $name 图片分类名称 | |
* @return array 返回新建分类情况 | |
*/ | |
public function addPictureCategory($name, $parentId = 0) | |
{ | |
if (! is_numeric($parentId)) { | |
return array( | |
'error_response' => array( | |
'code' => 300, | |
'msg' => '无效的 parent_id', | |
), | |
); | |
} | |
if (! is_string($fields) || $fields == '') { | |
return array( | |
'error_response' => array( | |
'code' => 300, | |
'msg' => '非法 fields', | |
), | |
); | |
} | |
$this->setMethod('taobao.picture.category.add'); | |
$tb->setParam('picture_category_name', $name); | |
$tb->setParam('parent_id', $parentId); | |
$res = $this->execute(); | |
$data = $res; | |
if (! isset($res['error_response'])) | |
$data = $res['picture_category_add_response']['picture_category']; | |
return $data; | |
} | |
public function uploadPicture($imgPath, $categoryId, $imageInputTitle, | |
$title = '', $clientType = 'client:computer') | |
{ | |
$this->setMethod('taobao.picture.upload'); | |
$this->setParam('img', '@' . $imgPath); | |
$this->setParam('picture_category_id', $categoryId); | |
$this->setParam('image_input_title', $imageInputTitle); | |
if (is_numeric($title)) | |
$this->setParam('title', $title); | |
if (in_array($clientType, array('client:computer', 'client:phone'))) | |
$this->setParam('client_type', $clientType); | |
$res = $this->execute(); | |
$data = $res; | |
if (! isset($res['error_response'])) | |
$data = $res['picture_upload_response']['picture']; | |
return $data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment