/** * 创建菜单 * * @author Cui * * @date 2015-08-23 * * @param array $button 菜单的数据 * @param int $agentId 应用ID */ public function create(array $button, $agentId) { if (empty($button) || empty($agentId)) { $this->setError('参数错误'); return false; } $data = array(); $data['button'] = $button; Api::setPostQueryStr('agentid', $agentId); $node = 'create'; return $this->_post($node, $data); }
/** * 上传临时媒体文件. * * @author Cui * * @date 2015-08-02 * * @param string $file 文件路径 * @param string $type 文件类型 * * @return 接口返回结果 */ public function upload($file, $type) { if (!$file || !$type) { $this->setError('参数缺失'); return false; } if (!file_exists($file)) { $this->setError('文件路径不正确'); return false; } // 兼容php5.3-5.6 curl模块的上传操作 if (class_exists('\\CURLFile')) { $data = array('media' => new \CURLFile(realpath($file))); } else { $data = array('media' => '@' . realpath($file)); } Api::setPostQueryStr('type', $type); $node = 'upload'; return $this->_post($node, $data, false); }