From e207494ef6aea59d43359f0d946970e187c345d4 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 3 Mar 2013 13:08:33 +0800 Subject: [PATCH 01/11] add readme --- README.md | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a8abe36 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ + +================= + +用于新浪微博开放平台的PHP SDK. 内含能直接使用的DEMO. + +SAE(Sina App Engine, http://sae.sina.com.cn )已内置SDK,不需要下载 + + +更新 +----- + ++ 2013年2月20日 修改V2版一处notice ++ 2011年12月16日 修改V2版两处手误 ++ 2011年10月21日 发布V2版PHP SDK,基于 http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2 中的最新接口封装。 ++ 2011年6月16日 发布OAuth2版PHP SDK,删除Basic认证的SDK(微博开放平台已不支持Basic认证) ++ 2010年11月17日 修改了demo程序默认callback url在某些访问方式下不正确的问题. ++ 2010年6月29日Basic认证版本&OAuth版本添加verify_credentials函数,用于获取当前用户信息,OAuth添加update_avatar更新头像 ++ 2010年5月5日 Basic 认证版本添加图片发布支持 ++ 2010年5月12日 OAuth 认证版本添加图片支持 + +说明 +----- +**Demo演示地址** + ++ V2版Demo: http://weibosdk.sinaapp.com/ ++ 站内应用Demo: http://apps.weibo.com/weibosdk ++ OAuth版Demo: http://saettest.sinaapp.com/ + +**如何申请API Key** + +你需要有一个新浪微博开放平台的API Key.这里申请: http://open.weibo.com + +**关于Class的功能** + ++ 基于OAuth认证. ++ 完成至2011年10月21日止,全部接口的封装 + +**新浪微博V2版PHPSDK Demo使用教程** + ++ 1.在open.weibo.com创建应用,得到API KEY,设置“授权设置”中的“应用回调页”地址为"http://host/callback.php",其中host为网站域名。 ++ 2.下载Demo,然后解压,修改config.php中的WB_AKEY为App Key,WB_SKEY为App Secret,WB_CALLBACK_URL为刚才填入的回调页地址。 ++ 3.上传到PHP空间即可 + +**新浪微博站内应用Demo使用教程** ++ 1.在open.weibo.com创建站内应用,得到API KEY ++ 2.编辑应用属性,设置"应用页面"中的“站内应用地址” ++ 3.下载,解压,修改config.php中的WB_AKEY为App Key,WB_SKEY为App Secret,CANVAS_PAGE为“应用页面”中设置的”站内应用地址“ ++ 4.上传代码到PHP空间 ++ 5.编辑应用属性,设置"应用页面"中的"应用实际地址"为刚刚上传代码的apps.php的地址,比如:"http://xxxxx.sinaapp.com/apps.php",设置“Iframe高度“为2000px。 ++ 6.访问刚刚设置的“站内应用地址”即可。 + +**OAuth版Demo使用教程** ++ 1.在open.weibo.com创建应用,得到API KEY ++ 2.下载,然后解压,修改config.php中的WB_AKEY为App Key,WB_SKEY为App Secret。 ++ 3.上传到PHP空间即可 + + +Bug tracker +----------- + +Have a bug? Please create an issue here on GitHub! + +https://github.com/xiaosier/libweibo/issues + + +Authors +------- + ++ http://weibo.com/lazypeople ++ http://skirt.sinaapp.com + + +License +--------------------- + +Copyright 2011 SINA, Inc. +Copyright 2011 SAE + +Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 \ No newline at end of file From 27494617309e2ec5ab786ca431c62dc3cbbd2c6d Mon Sep 17 00:00:00 2001 From: root Date: Sun, 3 Mar 2013 13:22:54 +0800 Subject: [PATCH 02/11] Finition format the code --- saetv2.ex.class.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/saetv2.ex.class.php b/saetv2.ex.class.php index 890a700..85b3aaa 100644 --- a/saetv2.ex.class.php +++ b/saetv2.ex.class.php @@ -1449,23 +1449,23 @@ function show_user_by_name( $screen_name ) } - /** - * 根据长链接获取短链 - * - * 根据长链接获取短链返地址。 - *
对应API:{@link http://open.weibo.com/wiki/2/short_url/shorten} - * - * @access public - * @param string $url 长链接地址。 - * @return array - */ - function get_short_url( $url ) - { - $params=array(); - if ( $url !== NULL ) { - $params['url_long'] = $url; - } - return $this->oauth->get( 'short_url/shorten', $params); + /** + * 根据长链接获取短链 + * + * 根据长链接获取短链返地址。 + *
对应API:{@link http://open.weibo.com/wiki/2/short_url/shorten} + * + * @access public + * @param string $url 长链接地址。 + * @return array + */ + function get_short_url( $url ) + { + $params=array(); + if ( $url !== NULL ) { + $params['url_long'] = $url; + } + return $this->oauth->get( 'short_url/shorten', $params); } /** From faa23feae28cf12ec601ceb4da361467ca0cb59e Mon Sep 17 00:00:00 2001 From: BliBly Date: Mon, 18 Mar 2013 10:54:54 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E9=87=8D=E5=AE=9A=E5=90=91=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0=E5=86=85=E5=AE=B9=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- saetv2.ex.class.php | 258 ++++++++++++++++++++++++-------------------- 1 file changed, 139 insertions(+), 119 deletions(-) diff --git a/saetv2.ex.class.php b/saetv2.ex.class.php index 85b3aaa..38e96ea 100644 --- a/saetv2.ex.class.php +++ b/saetv2.ex.class.php @@ -1,7 +1,7 @@ */ @@ -40,7 +40,7 @@ class SaeTOAuthV2 { */ public $refresh_token; /** - * Contains the last HTTP status code returned. + * Contains the last HTTP status code returned. * * @ignore */ @@ -143,13 +143,13 @@ function __construct($client_id, $client_secret, $access_token = NULL, $refresh_ * @param string $url 授权后的回调地址,站外应用需与回调地址一致,站内应用需要填写canvas page的地址 * @param string $response_type 支持的值包括 code 和token 默认值为code * @param string $state 用于保持请求和回调的状态。在回调时,会在Query Parameter中回传该参数 - * @param string $display 授权页面类型 可选范围: - * - default 默认授权页面 - * - mobile 支持html5的手机 - * - popup 弹窗授权页 - * - wap1.2 wap1.2页面 - * - wap2.0 wap2.0页面 - * - js js-sdk 专用 授权页面是弹窗,返回结果为js-sdk回掉函数 + * @param string $display 授权页面类型 可选范围: + * - default 默认授权页面 + * - mobile 支持html5的手机 + * - popup 弹窗授权页 + * - wap1.2 wap1.2页面 + * - wap2.0 wap2.0页面 + * - js js-sdk 专用 授权页面是弹窗,返回结果为js-sdk回掉函数 * - apponweibo 站内应用专用,站内应用不传display参数,并且response_type为token时,默认使用改display.授权后不会返回access_token,只是输出js刷新站内应用父框架 * @return array */ @@ -213,7 +213,7 @@ function getAccessToken( $type = 'code', $keys ) { * @return array */ function parseSignedRequest($signed_request) { - list($encoded_sig, $payload) = explode('.', $signed_request, 2); + list($encoded_sig, $payload) = explode('.', $signed_request, 2); $sig = self::base64decode($encoded_sig) ; $data = json_decode(self::base64decode($payload), true); if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') return '-1'; @@ -448,7 +448,7 @@ public static function build_http_query_multi($params) { if( in_array($parameter, array('pic', 'image')) && $value{0} == '@' ) { $url = ltrim( $value, '@' ); - $content = file_get_contents( $url ); + $content = curl_get_file_contents( $url ); $array = explode( '?', basename( $url ) ); $filename = $array[0]; @@ -467,6 +467,26 @@ public static function build_http_query_multi($params) { $multipartbody .= $endMPboundary; return $multipartbody; } + + /** + * @ignore + */ + public function curl_get_file_contents($durl) { + $ch = curl_init($durl); + $options = array( + CURLOPT_RETURNTRANSFER => true, + CURLOPT_FOLLOWLOCATION => true, // redirects + CURLOPT_USERAGENT => "Sina App Engine", + CURLOPT_AUTOREFERER => true, + CURLOPT_CONNECTTIMEOUT => 120, + CURLOPT_TIMEOUT => 120, + CURLOPT_MAXREDIRS => 10, + ); + curl_setopt_array( $ch, $options ); + $r = curl_exec($ch); + curl_close($ch); + return $r; + } } @@ -483,7 +503,7 @@ class SaeTClientV2 { /** * 构造函数 - * + * * @access public * @param mixed $akey 微博开放平台应用APP KEY * @param mixed $skey 微博开放平台应用APP SECRET @@ -554,7 +574,7 @@ function public_timeline( $page = 1, $count = 50, $base_app = 0 ) * * 获取当前登录用户及其所关注用户的最新微博消息。和用户登录 http://weibo.com 后在“我的首页”中看到的内容相同。同friends_timeline() *
对应API:{@link http://open.weibo.com/wiki/2/statuses/home_timeline statuses/home_timeline} - * + * * @access public * @param int $page 指定返回结果的页码。根据当前登录用户所关注的用户数及这些被关注用户发表的微博数,翻页功能最多能查看的总记录数会有所不同,通常最多能查看1000条左右。默认值1。可选。 * @param int $count 每次返回的记录数。缺省值50,最大值200。可选。 @@ -588,7 +608,7 @@ function home_timeline( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $bas * * 获取当前登录用户及其所关注用户的最新微博消息。和用户登录 http://weibo.com 后在“我的首页”中看到的内容相同。同home_timeline() *
对应API:{@link http://open.weibo.com/wiki/2/statuses/friends_timeline statuses/friends_timeline} - * + * * @access public * @param int $page 指定返回结果的页码。根据当前登录用户所关注的用户数及这些被关注用户发表的微博数,翻页功能最多能查看的总记录数会有所不同,通常最多能查看1000条左右。默认值1。可选。 * @param int $count 每次返回的记录数。缺省值50,最大值200。可选。 @@ -608,7 +628,7 @@ function friends_timeline( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $ * * 返回用户的发布的最近n条信息,和用户微博页面返回内容是一致的。此接口也可以请求其他用户的最新发表微博。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/user_timeline statuses/user_timeline} - * + * * @access public * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 @@ -640,16 +660,16 @@ function user_timeline_by_id( $uid = NULL , $page = 1 , $count = 50 , $since_id return $this->oauth->get( 'statuses/user_timeline', $params ); } - - + + /** * 获取用户发布的微博信息列表 * * 返回用户的发布的最近n条信息,和用户微博页面返回内容是一致的。此接口也可以请求其他用户的最新发表微博。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/user_timeline statuses/user_timeline} - * + * * @access public - * @param string $screen_name 微博昵称,主要是用来区分用户UID跟微博昵称,当二者一样而产生歧义的时候,建议使用该参数 + * @param string $screen_name 微博昵称,主要是用来区分用户UID跟微博昵称,当二者一样而产生歧义的时候,建议使用该参数 * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 * @param int $since_id 若指定此参数,则只返回ID比since_id大的微博消息(即比since_id发表时间晚的微博消息)。可选。 @@ -679,9 +699,9 @@ function user_timeline_by_name( $screen_name = NULL , $page = 1 , $count = 50 , return $this->oauth->get( 'statuses/user_timeline', $params ); } - - - + + + /** * 批量获取指定的一批用户的timeline * @@ -689,7 +709,7 @@ function user_timeline_by_name( $screen_name = NULL , $page = 1 , $count = 50 , * * @param string $screen_name 需要查询的用户昵称,用半角逗号分隔,一次最多20个 * @param int $count 单页返回的记录条数,默认为50。 - * @param int $page 返回结果的页码,默认为1。 + * @param int $page 返回结果的页码,默认为1。 * @param int $base_app 是否只获取当前应用的数据。0为否(所有数据),1为是(仅当前应用),默认为0。 * @param int $feature 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。 * @return array @@ -703,7 +723,7 @@ function timeline_batch_by_name( $screen_name, $page = 1, $count = 50, $feature $params['screen_name'] = $screen_name; } $params['count'] = intval($count); - $params['page'] = intval($page); + $params['page'] = intval($page); $params['base_app'] = intval($base_app); $params['feature'] = intval($feature); return $this->oauth->get('statuses/timeline_batch', $params); @@ -716,7 +736,7 @@ function timeline_batch_by_name( $screen_name, $page = 1, $count = 50, $feature * * @param string $uids 需要查询的用户ID,用半角逗号分隔,一次最多20个。 * @param int $count 单页返回的记录条数,默认为50。 - * @param int $page 返回结果的页码,默认为1。 + * @param int $page 返回结果的页码,默认为1。 * @param int $base_app 是否只获取当前应用的数据。0为否(所有数据),1为是(仅当前应用),默认为0。 * @param int $feature 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。 * @return array @@ -733,7 +753,7 @@ function timeline_batch_by_id( $uids, $page = 1, $count = 50, $feature = 0, $bas $params['uids'] = $uids; } $params['count'] = intval($count); - $params['page'] = intval($page); + $params['page'] = intval($page); $params['base_app'] = intval($base_app); $params['feature'] = intval($feature); return $this->oauth->get('statuses/timeline_batch', $params); @@ -741,13 +761,13 @@ function timeline_batch_by_id( $uids, $page = 1, $count = 50, $feature = 0, $bas /** - * 返回一条原创微博消息的最新n条转发微博消息。本接口无法对非原创微博进行查询。 + * 返回一条原创微博消息的最新n条转发微博消息。本接口无法对非原创微博进行查询。 * * 对应API:{@link http://open.weibo.com/wiki/2/statuses/repost_timeline statuses/repost_timeline} - * + * * @access public * @param int $sid 要获取转发微博列表的原创微博ID。 - * @param int $page 返回结果的页码。 + * @param int $page 返回结果的页码。 * @param int $count 单页返回的最大记录数,最多返回200条,默认50。可选。 * @param int $since_id 若指定此参数,则只返回ID比since_id大的记录(比since_id发表时间晚)。可选。 * @param int $max_id 若指定此参数,则返回ID小于或等于max_id的记录。可选。 @@ -777,9 +797,9 @@ function repost_timeline( $sid, $page = 1, $count = 50, $since_id = 0, $max_id = * 获取当前用户最新转发的n条微博消息 * * 对应API:{@link http://open.weibo.com/wiki/2/statuses/repost_by_me statuses/repost_by_me} - * + * * @access public - * @param int $page 返回结果的页码。 + * @param int $page 返回结果的页码。 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。可选。 * @param int $since_id 若指定此参数,则只返回ID比since_id大的记录(比since_id发表时间晚)。可选。 * @param int $max_id 若指定此参数,则返回ID小于或等于max_id的记录。可选。 @@ -805,7 +825,7 @@ function repost_by_me( $page = 1, $count = 50, $since_id = 0, $max_id = 0 ) * * 返回最新n条提到登录用户的微博消息(即包含@username的微博消息) *
对应API:{@link http://open.weibo.com/wiki/2/statuses/mentions statuses/mentions} - * + * * @access public * @param int $page 返回结果的页序号。 * @param int $count 每次返回的最大记录数(即页面大小),不大于200,默认为50。 @@ -840,7 +860,7 @@ function mentions( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $filter_b * * 获取单条ID的微博信息,作者信息将同时返回。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/show statuses/show} - * + * * @access public * @param int $id 要获取已发表的微博ID, 如ID不存在返回空 * @return array @@ -991,7 +1011,7 @@ function comments_weekly( $count = 20, $base_app = 0) * * 可加评论。为防止重复,发布的信息与最新信息一样话,将会被忽略。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/repost statuses/repost} - * + * * @access public * @param int $sid 转发的微博ID * @param string $text 添加的评论信息。可选。 @@ -1012,10 +1032,10 @@ function repost( $sid, $text = NULL, $is_comment = 0 ) /** * 删除一条微博 - * + * * 根据ID删除微博消息。注意:只能删除自己发布的信息。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/destroy statuses/destroy} - * + * * @access public * @param int $id 要删除的微博ID * @return array @@ -1030,7 +1050,7 @@ function delete( $id ) * * 删除微博。注意:只能删除自己发布的信息。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/destroy statuses/destroy} - * + * * @access public * @param int $id 要删除的微博ID * @return array @@ -1043,15 +1063,15 @@ function destroy( $id ) return $this->oauth->post( 'statuses/destroy', $params ); } - + /** * 发表微博 * * 发布一条微博信息。 *
注意:lat和long参数需配合使用,用于标记发表微博消息时所在的地理位置,只有用户设置中geo_enabled=true时候地理位置信息才有效。 - *
注意:为防止重复提交,当用户发布的微博消息与上次成功发布的微博消息内容一样时,将返回400错误,给出错误提示:“40025:Error: repeated weibo text!“。 + *
注意:为防止重复提交,当用户发布的微博消息与上次成功发布的微博消息内容一样时,将返回400错误,给出错误提示:“40025:Error: repeated weibo text!“。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/update statuses/update} - * + * * @access public * @param string $status 要更新的微博信息。信息内容不超过140个汉字, 为空返回400错误。 * @param float $lat 纬度,发表当前微博所在的地理位置,有效范围 -90.0到+90.0, +表示北纬。可选。 @@ -1081,10 +1101,10 @@ function update( $status, $lat = NULL, $long = NULL, $annotations = NULL ) /** * 发表图片微博 * - * 发表图片微博消息。目前上传图片大小限制为<5M。 + * 发表图片微博消息。目前上传图片大小限制为<5M。 *
注意:lat和long参数需配合使用,用于标记发表微博消息时所在的地理位置,只有用户设置中geo_enabled=true时候地理位置信息才有效。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/upload statuses/upload} - * + * * @access public * @param string $status 要更新的微博信息。信息内容不超过140个汉字, 为空返回400错误。 * @param string $pic_path 要发布的图片路径, 支持url。[只支持png/jpg/gif三种格式, 增加格式请修改get_image_mime方法] @@ -1131,7 +1151,7 @@ function upload_url_text( $status, $url ) * * 返回新浪微博官方所有表情、魔法表情的相关信息。包括短语、表情类型、表情分类,是否热门等。 *
对应API:{@link http://open.weibo.com/wiki/2/emotions emotions} - * + * * @access public * @param string $type 表情类别。"face":普通表情,"ani":魔法表情,"cartoon":动漫表情。默认为"face"。可选。 * @param string $language 语言类别,"cnname"简体,"twname"繁体。默认为"cnname"。可选 @@ -1220,7 +1240,7 @@ function comments_by_me( $page = 1 , $count = 50, $since_id = 0, $max_id = 0, $ * @param int $filter_by_author 作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。 * @param int $filter_by_source 来源筛选类型,0:全部、1:来自微博的评论、2:来自微群的评论,默认为0。 * @return array - */ + */ function comments_to_me( $page = 1 , $count = 50, $since_id = 0, $max_id = 0, $filter_by_author = 0, $filter_by_source = 0) { $params = array(); @@ -1244,7 +1264,7 @@ function comments_to_me( $page = 1 , $count = 50, $since_id = 0, $max_id = 0, $f * * 返回最新n条发送及收到的评论。 *
对应API:{@link http://open.weibo.com/wiki/2/comments/timeline comments/timeline} - * + * * @access public * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 @@ -1280,7 +1300,7 @@ function comments_timeline( $page = 1, $count = 50, $since_id = 0, $max_id = 0 ) * @param int $filter_by_author 作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。 * @param int $filter_by_source 来源筛选类型,0:全部、1:来自微博的评论、2:来自微群的评论,默认为0。 * @return array - */ + */ function comments_mentions( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $filter_by_author = 0, $filter_by_source = 0) { $params = array(); @@ -1342,7 +1362,7 @@ function send_comment( $id , $comment , $comment_ori = 0) * * 注意:只能删除自己发布的评论,发部微博的用户不可以删除其他人的评论。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/comment_destroy statuses/comment_destroy} - * + * * @access public * @param int $cid 要删除的评论id * @return array @@ -1385,7 +1405,7 @@ function comment_destroy_batch( $ids ) * * 为防止重复,发布的信息与最后一条评论/回复信息一样话,将会被忽略。 *
对应API:{@link http://open.weibo.com/wiki/2/comments/reply comments/reply} - * + * * @access public * @param int $sid 微博id * @param string $text 评论内容。 @@ -1414,7 +1434,7 @@ function reply( $sid, $text, $cid, $without_mention = 0, $comment_ori = 0 ) * * 按用户UID或昵称返回用户资料,同时也将返回用户的最新发布的微博。 *
对应API:{@link http://open.weibo.com/wiki/2/users/show users/show} - * + * * @access public * @param int $uid 用户UID。 * @return array @@ -1429,13 +1449,13 @@ function show_user_by_id( $uid ) return $this->oauth->get('users/show', $params ); } - + /** * 根据用户UID或昵称获取用户资料 * * 按用户UID或昵称返回用户资料,同时也将返回用户的最新发布的微博。 *
对应API:{@link http://open.weibo.com/wiki/2/users/show users/show} - * + * * @access public * @param string $screen_name 用户UID。 * @return array @@ -1447,14 +1467,14 @@ function show_user_by_name( $screen_name ) return $this->oauth->get( 'users/show', $params ); } - - + + /** * 根据长链接获取短链 * * 根据长链接获取短链返地址。 *
对应API:{@link http://open.weibo.com/wiki/2/short_url/shorten} - * + * * @access public * @param string $url 长链接地址。 * @return array @@ -1472,7 +1492,7 @@ function get_short_url( $url ) * 通过个性化域名获取用户资料以及用户最新的一条微博 * * 对应API:{@link http://open.weibo.com/wiki/2/users/domain_show users/domain_show} - * + * * @access public * @param mixed $domain 用户个性域名。例如:lazypeople,而不是http://weibo.com/lazypeople * @return array @@ -1505,7 +1525,7 @@ function users_show_batch_by_id( $uids ) } return $this->oauth->get( 'users/show_batch', $params ); } - + /** * 批量获取用户信息按screen_name * @@ -1531,7 +1551,7 @@ function users_show_batch_by_name( $screen_name ) * * 如果没有提供cursor参数,将只返回最前面的5000个关注id *
对应API:{@link http://open.weibo.com/wiki/2/friendships/friends friendships/friends} - * + * * @access public * @param int $cursor 返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。 * @param int $count 单页返回的记录条数,默认为50,最大不超过200。 @@ -1547,14 +1567,14 @@ function friends_by_id( $uid, $cursor = 0, $count = 50 ) return $this->oauth->get( 'friendships/friends', $params ); } - - + + /** * 获取用户的关注列表 * * 如果没有提供cursor参数,将只返回最前面的5000个关注id *
对应API:{@link http://open.weibo.com/wiki/2/friendships/friends friendships/friends} - * + * * @access public * @param int $cursor 返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。 * @param int $count 单页返回的记录条数,默认为50,最大不超过200。 @@ -1639,7 +1659,7 @@ function bilateral_ids( $uid, $page = 1, $count = 50, $sort = 0) * * 如果没有提供cursor参数,将只返回最前面的5000个关注id *
对应API:{@link http://open.weibo.com/wiki/2/friendships/friends/ids friendships/friends/ids} - * + * * @access public * @param int $cursor 返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。 * @param int $count 每次返回的最大记录数(即页面大小),不大于5000, 默认返回500。 @@ -1655,13 +1675,13 @@ function friends_ids_by_id( $uid, $cursor = 0, $count = 500 ) $params['count'] = $count; return $this->oauth->get( 'friendships/friends/ids', $params ); } - + /** * 获取用户的关注列表uid * * 如果没有提供cursor参数,将只返回最前面的5000个关注id *
对应API:{@link http://open.weibo.com/wiki/2/friendships/friends/ids friendships/friends/ids} - * + * * @access public * @param int $cursor 返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。 * @param int $count 每次返回的最大记录数(即页面大小),不大于5000, 默认返回500。 @@ -1719,7 +1739,7 @@ function followers_by_id( $uid , $cursor = 0 , $count = 50) $params['cursor'] = $cursor; return $this->oauth->get( 'friendships/followers', $params ); } - + /** * 获取用户的粉丝列表 * @@ -1758,7 +1778,7 @@ function followers_ids_by_id( $uid, $cursor = 0 , $count = 50 ) $params['cursor'] = $cursor; return $this->oauth->get( 'friendships/followers/ids', $params ); } - + /** * 获取用户的粉丝列表uid * @@ -1822,7 +1842,7 @@ function friends_chain_followers( $uid, $page = 1, $count = 50 ) * * 如果源用户或目的用户不存在,将返回http的400错误 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/show friendships/show} - * + * * @access public * @param mixed $target_id 目标用户UID * @param mixed $source_id 源用户UID,可选,默认为当前的用户 @@ -1847,7 +1867,7 @@ function is_followed_by_id( $target_id, $source_id = NULL ) * * 如果源用户或目的用户不存在,将返回http的400错误 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/show friendships/show} - * + * * @access public * @param mixed $target_name 目标用户的微博昵称 * @param mixed $source_name 源用户的微博昵称,可选,默认为当前的用户 @@ -1870,7 +1890,7 @@ function is_followed_by_name( $target_name, $source_name = NULL ) * * 成功则返回关注人的资料,目前最多关注2000人,失败则返回一条字符串的说明。如果已经关注了此人,则返回http 403的状态。关注不存在的ID将返回400。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/create friendships/create} - * + * * @access public * @param int $uid 要关注的用户UID * @return array @@ -1882,13 +1902,13 @@ function follow_by_id( $uid ) $params['uid'] = $uid; return $this->oauth->post( 'friendships/create', $params ); } - + /** * 关注一个用户。 * * 成功则返回关注人的资料,目前的最多关注2000人,失败则返回一条字符串的说明。如果已经关注了此人,则返回http 403的状态。关注不存在的ID将返回400。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/create friendships/create} - * + * * @access public * @param string $screen_name 要关注的用户昵称 * @return array @@ -1928,7 +1948,7 @@ function follow_create_batch( $uids ) * * 取消关注某用户。成功则返回被取消关注人的资料,失败则返回一条字符串的说明。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/destroy friendships/destroy} - * + * * @access public * @param int $uid 要取消关注的用户UID * @return array @@ -1940,13 +1960,13 @@ function unfollow_by_id( $uid ) $params['uid'] = $uid; return $this->oauth->post( 'friendships/destroy', $params); } - + /** * 取消关注某用户 * * 取消关注某用户。成功则返回被取消关注人的资料,失败则返回一条字符串的说明。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/destroy friendships/destroy} - * + * * @access public * @param string $screen_name 要取消关注的用户昵称 * @return array @@ -1963,7 +1983,7 @@ function unfollow_by_name( $screen_name ) * * 只能修改当前登录用户所关注的用户的备注信息。否则将给出400错误。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/remark/update friendships/remark/update} - * + * * @access public * @param int $uid 需要修改备注信息的用户ID。 * @param string $remark 备注信息。 @@ -1983,7 +2003,7 @@ function update_remark( $uid, $remark ) * * 返回用户的最新n条私信,并包含发送者和接受者的详细资料。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages direct_messages} - * + * * @access public * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 @@ -2011,7 +2031,7 @@ function list_dm( $page = 1, $count = 50, $since_id = 0, $max_id = 0 ) * * 返回登录用户已发送最新50条私信。包括发送者和接受者的详细资料。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/sent direct_messages/sent} - * + * * @access public * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 @@ -2050,7 +2070,7 @@ function dm_user_list( $count = 20, $cursor = 0) $params['count'] = $count; $params['cursor'] = $cursor; return $this->oauth->get( 'direct_messages/user_list', $params ); - } + } /** * 获取与指定用户的往来私信列表 @@ -2109,7 +2129,7 @@ function dm_show_batch( $dmids ) * * 发送一条私信。成功将返回完整的发送消息。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/new direct_messages/new} - * + * * @access public * @param int $uid 用户UID * @param string $text 要发生的消息内容,文本大小必须小于300个汉字。 @@ -2128,13 +2148,13 @@ function send_dm_by_id( $uid, $text, $id = NULL ) } return $this->oauth->post( 'direct_messages/new', $params ); } - + /** * 发送私信 * * 发送一条私信。成功将返回完整的发送消息。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/new direct_messages/new} - * + * * @access public * @param string $screen_name 用户昵称 * @param string $text 要发生的消息内容,文本大小必须小于300个汉字。 @@ -2158,7 +2178,7 @@ function send_dm_by_name( $screen_name, $text, $id = NULL ) * * 按ID删除私信。操作用户必须为私信的接收人。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/destroy direct_messages/destroy} - * + * * @access public * @param int $did 要删除的私信主键ID * @return array @@ -2176,7 +2196,7 @@ function delete_dm( $did ) * * 批量删除当前登录用户的私信。出现异常时,返回400错误。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/destroy_batch direct_messages/destroy_batch} - * + * * @access public * @param mixed $dids 欲删除的一组私信ID,用半角逗号隔开,或者由一组评论ID组成的数组。最多20个。例如:"4976494627, 4976262053"或array(4976494627,4976262053); * @return array @@ -2195,7 +2215,7 @@ function delete_dms( $dids ) return $this->oauth->post( 'direct_messages/destroy_batch', $params); } - + /** @@ -2303,7 +2323,7 @@ function account_career_batch( $uids ) * 获取隐私信息设置情况 * * 对应API:{@link http://open.weibo.com/wiki/2/account/get_privacy account/get_privacy} - * + * * @access public * @return array */ @@ -2340,7 +2360,7 @@ function school_list( $query ) * 获取当前登录用户的API访问频率限制情况 * * 对应API:{@link http://open.weibo.com/wiki/2/account/rate_limit_status account/rate_limit_status} - * + * * @access public * @return array */ @@ -2353,7 +2373,7 @@ function rate_limit_status() * OAuth授权之后,获取授权用户的UID * * 对应API:{@link http://open.weibo.com/wiki/2/account/get_uid account/get_uid} - * + * * @access public * @return array */ @@ -2367,7 +2387,7 @@ function get_uid() * 更改用户资料 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/basic_update account/profile/basic_update} - * + * * @access public * @param array $profile 要修改的资料。格式:array('key1'=>'value1', 'key2'=>'value2', .....)。 * 支持修改的项: @@ -2407,7 +2427,7 @@ function update_profile( $profile ) * 设置教育信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/edu_update account/profile/edu_update} - * + * * @access public * @param array $edu_update 要修改的学校信息。格式:array('key1'=>'value1', 'key2'=>'value2', .....)。 * 支持设置的项: @@ -2428,7 +2448,7 @@ function edu_update( $edu_update ) * 根据学校ID删除用户的教育信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/edu_destroy account/profile/edu_destroy} - * + * * @param int $id 教育信息里的学校ID。 * @return array */ @@ -2444,7 +2464,7 @@ function edu_destroy( $id ) * 设置职业信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/car_update account/profile/car_update} - * + * * @param array $car_update 要修改的职业信息。格式:array('key1'=>'value1', 'key2'=>'value2', .....)。 * 支持设置的项: * - id string 需要更新的职业信息ID。 @@ -2468,7 +2488,7 @@ function car_update( $car_update ) * 根据公司ID删除用户的职业信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/car_destroy account/profile/car_destroy} - * + * * @access public * @param int $id 职业信息里的公司ID * @return array @@ -2501,7 +2521,7 @@ function update_profile_image( $image_path ) * 设置隐私信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/update_privacy account/update_privacy} - * + * * @param array $privacy_settings 要修改的隐私设置。格式:array('key1'=>'value1', 'key2'=>'value2', .....)。 * 支持设置的项: * - comment int 是否可以评论我的微博,0:所有人、1:关注的人,默认为0。 @@ -2524,7 +2544,7 @@ function update_privacy( $privacy_settings ) * * 返回用户的发布的最近20条收藏信息,和用户收藏页面返回内容是一致的。 *
对应API:{@link http://open.weibo.com/wiki/2/favorites favorites} - * + * * @access public * @param int $page 返回结果的页码,默认为1。 * @param int $count 单页返回的记录条数,默认为50。 @@ -2545,7 +2565,7 @@ function get_favorites( $page = 1, $count = 50 ) * * 根据收藏ID获取指定的收藏信息。 *
对应API:{@link http://open.weibo.com/wiki/2/favorites/show favorites/show} - * + * * @access public * @param int $id 需要查询的收藏ID。 * @return array @@ -2564,7 +2584,7 @@ function favorites_show( $id ) * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/by_tags favorites/by_tags} * - * + * * @param int $tid 需要查询的标签ID。' * @param int $count 单页返回的记录条数,默认为50。 * @param int $page 返回结果的页码,默认为1。 @@ -2584,7 +2604,7 @@ function favorites_by_tags( $tid, $page = 1, $count = 50) * 获取当前登录用户的收藏标签列表 * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/tags favorites/tags} - * + * * @access public * @param int $count 单页返回的记录条数,默认为50。 * @param int $page 返回结果的页码,默认为1。 @@ -2603,7 +2623,7 @@ function favorites_tags( $page = 1, $count = 50) * 收藏一条微博信息 * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/create favorites/create} - * + * * @access public * @param int $sid 收藏的微博id * @return array @@ -2621,7 +2641,7 @@ function add_to_favorites( $sid ) * 删除微博收藏。 * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/destroy favorites/destroy} - * + * * @access public * @param int $id 要删除的收藏微博信息ID. * @return array @@ -2640,7 +2660,7 @@ function remove_from_favorites( $id ) * * 批量删除当前登录用户的收藏。出现异常时,返回HTTP400错误。 *
对应API:{@link http://open.weibo.com/wiki/2/favorites/destroy_batch favorites/destroy_batch} - * + * * @access public * @param mixed $fids 欲删除的一组私信ID,用半角逗号隔开,或者由一组评论ID组成的数组。最多20个。例如:"231101027525486630,201100826122315375"或array(231101027525486630,201100826122315375); * @return array @@ -2665,7 +2685,7 @@ function remove_from_favorites_batch( $fids ) * 更新一条收藏的收藏标签 * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/tags/update favorites/tags/update} - * + * * @access public * @param int $id 需要更新的收藏ID。 * @param string $tags 需要更新的标签内容,用半角逗号分隔,最多不超过2条。 @@ -2723,7 +2743,7 @@ function favorites_tags_destroy_batch( $tid ) * 获取某用户的话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends trends} - * + * * @param int $uid 查询用户的ID。默认为当前用户。可选。 * @param int $page 指定返回结果的页码。可选。 * @param int $count 单页大小。缺省值10。可选。 @@ -2749,7 +2769,7 @@ function get_trends( $uid = NULL, $page = 1, $count = 10 ) * 判断当前用户是否关注某话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/is_follow trends/is_follow} - * + * * @access public * @param string $trend_name 话题关键字。 * @return array @@ -2765,7 +2785,7 @@ function trends_is_follow( $trend_name ) * 返回最近一小时内的热门话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/hourly trends/hourly} - * + * * @param int $base_app 是否基于当前应用来获取数据。1表示基于当前应用来获取数据,默认为0。可选。 * @return array */ @@ -2781,7 +2801,7 @@ function hourly_trends( $base_app = 0 ) * 返回最近一天内的热门话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/daily trends/daily} - * + * * @param int $base_app 是否基于当前应用来获取数据。1表示基于当前应用来获取数据,默认为0。可选。 * @return array */ @@ -2797,7 +2817,7 @@ function daily_trends( $base_app = 0 ) * 返回最近一周内的热门话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/weekly trends/weekly} - * + * * @access public * @param int $base_app 是否基于当前应用来获取数据。1表示基于当前应用来获取数据,默认为0。可选。 * @return array @@ -2814,7 +2834,7 @@ function weekly_trends( $base_app = 0 ) * 关注某话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/follow trends/follow} - * + * * @access public * @param string $trend_name 要关注的话题关键词。 * @return array @@ -2830,7 +2850,7 @@ function follow_trends( $trend_name ) * 取消对某话题的关注 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/destroy trends/destroy} - * + * * @access public * @param int $tid 要取消关注的话题ID。 * @return array @@ -2849,7 +2869,7 @@ function unfollow_trends( $tid ) * 返回指定用户的标签列表 * * 对应API:{@link http://open.weibo.com/wiki/2/tags tags} - * + * * @param int $uid 查询用户的ID。默认为当前用户。可选。 * @param int $page 指定返回结果的页码。可选。 * @param int $count 单页大小。缺省值20,最大值200。可选。 @@ -2874,7 +2894,7 @@ function get_tags( $uid = NULL, $page = 1, $count = 20 ) * 批量获取用户的标签列表 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/tags_batch tags/tags_batch} - * + * * @param string $uids 要获取标签的用户ID。最大20,逗号分隔。必填 * @return array */ @@ -2896,7 +2916,7 @@ function get_tags_batch( $uids ) * 返回用户感兴趣的标签 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/suggestions tags/suggestions} - * + * * @access public * @param int $count 单页大小。缺省值10,最大值10。可选。 * @return array @@ -2912,7 +2932,7 @@ function get_suggest_tags( $count = 10) * 为当前登录用户添加新的用户标签 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/create tags/create} - * + * * @access public * @param mixed $tags 要创建的一组标签,每个标签的长度不可超过7个汉字,14个半角字符。多个标签之间用逗号间隔,或由多个标签构成的数组。如:"abc,drf,efgh,tt"或array("abc", "drf", "efgh", "tt") * @return array @@ -2932,7 +2952,7 @@ function add_tags( $tags ) * 删除标签 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/destroy tags/destroy} - * + * * @access public * @param int $tag_id 标签ID,必填参数 * @return array @@ -2948,7 +2968,7 @@ function delete_tag( $tag_id ) * 批量删除标签 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/destroy_batch tags/destroy_batch} - * + * * @access public * @param mixed $ids 必选参数,要删除的tag id,多个id用半角逗号分割,最多10个。或由多个tag id构成的数组。如:“553,554,555"或array(553, 554, 555) * @return array @@ -3077,7 +3097,7 @@ function search_at_users( $q, $count = 10, $type=0, $range = 2) } - + /** @@ -3143,7 +3163,7 @@ function search_users_keywords( $query ) * * 返回系统推荐的用户列表。 *
对应API:{@link http://open.weibo.com/wiki/2/suggestions/users/hot suggestions/users/hot} - * + * * @access public * @param string $category 分类,可选参数,返回某一类别的推荐用户,默认为 default。如果不在以下分类中,返回空列表:
* - default:人气关注 @@ -3173,7 +3193,7 @@ function hot_users( $category = "default" ) * 获取用户可能感兴趣的人 * * 对应API:{@link http://open.weibo.com/wiki/2/suggestions/users/may_interested suggestions/users/may_interested} - * + * * @access public * @param int $page 返回结果的页码,默认为1。 * @param int $count 单页返回的记录条数,默认为10。 @@ -3181,7 +3201,7 @@ function hot_users( $category = "default" ) * @ignore */ function suggestions_may_interested( $page = 1, $count = 10 ) - { + { $params = array(); $params['page'] = $page; $params['count'] = $count; @@ -3189,10 +3209,10 @@ function suggestions_may_interested( $page = 1, $count = 10 ) } /** - * 根据一段微博正文推荐相关微博用户。 + * 根据一段微博正文推荐相关微博用户。 * * 对应API:{@link http://open.weibo.com/wiki/2/suggestions/users/by_status suggestions/users/by_status} - * + * * @access public * @param string $content 微博正文内容。 * @param int $num 返回结果数目,默认为10。 From 4fe3f4c7248e72a27f054f508c59063dadc16bcc Mon Sep 17 00:00:00 2001 From: custool Date: Wed, 20 Mar 2013 13:23:53 +0800 Subject: [PATCH 04/11] =?UTF-8?q?curl=5Fget=5Ffile=5Fcontents=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E8=B0=83=E7=94=A8=E6=9C=89=E7=82=B9=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BA=E9=9D=99=E6=80=81=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- saetv2.ex.class.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/saetv2.ex.class.php b/saetv2.ex.class.php index 38e96ea..b3f47d7 100644 --- a/saetv2.ex.class.php +++ b/saetv2.ex.class.php @@ -448,7 +448,7 @@ public static function build_http_query_multi($params) { if( in_array($parameter, array('pic', 'image')) && $value{0} == '@' ) { $url = ltrim( $value, '@' ); - $content = curl_get_file_contents( $url ); + $content = self::curl_get_file_contents( $url ); $array = explode( '?', basename( $url ) ); $filename = $array[0]; @@ -471,22 +471,22 @@ public static function build_http_query_multi($params) { /** * @ignore */ - public function curl_get_file_contents($durl) { - $ch = curl_init($durl); - $options = array( - CURLOPT_RETURNTRANSFER => true, - CURLOPT_FOLLOWLOCATION => true, // redirects - CURLOPT_USERAGENT => "Sina App Engine", - CURLOPT_AUTOREFERER => true, - CURLOPT_CONNECTTIMEOUT => 120, - CURLOPT_TIMEOUT => 120, - CURLOPT_MAXREDIRS => 10, - ); - curl_setopt_array( $ch, $options ); - $r = curl_exec($ch); - curl_close($ch); - return $r; - } + public static function curl_get_file_contents($durl) { + $ch = curl_init($durl); + $options = array( + CURLOPT_RETURNTRANSFER => true, + CURLOPT_FOLLOWLOCATION => true, // redirects + CURLOPT_USERAGENT => "Sina App Engine", + CURLOPT_AUTOREFERER => true, + CURLOPT_CONNECTTIMEOUT => 120, + CURLOPT_TIMEOUT => 120, + CURLOPT_MAXREDIRS => 10, + ); + curl_setopt_array( $ch, $options ); + $r = curl_exec($ch); + curl_close($ch); + return $r; + } } From e26461bcdd8ce2a97d3c8493adaadca5dcedf4ae Mon Sep 17 00:00:00 2001 From: mingming6 Date: Wed, 10 Jul 2013 10:50:25 +0800 Subject: [PATCH 05/11] Fix upload_url_text bug --- saetv2.ex.class.php | 299 +++++++++++++++++++++----------------------- 1 file changed, 141 insertions(+), 158 deletions(-) diff --git a/saetv2.ex.class.php b/saetv2.ex.class.php index b3f47d7..506eb03 100644 --- a/saetv2.ex.class.php +++ b/saetv2.ex.class.php @@ -1,7 +1,7 @@ */ @@ -40,7 +40,7 @@ class SaeTOAuthV2 { */ public $refresh_token; /** - * Contains the last HTTP status code returned. + * Contains the last HTTP status code returned. * * @ignore */ @@ -143,13 +143,13 @@ function __construct($client_id, $client_secret, $access_token = NULL, $refresh_ * @param string $url 授权后的回调地址,站外应用需与回调地址一致,站内应用需要填写canvas page的地址 * @param string $response_type 支持的值包括 code 和token 默认值为code * @param string $state 用于保持请求和回调的状态。在回调时,会在Query Parameter中回传该参数 - * @param string $display 授权页面类型 可选范围: - * - default 默认授权页面 - * - mobile 支持html5的手机 - * - popup 弹窗授权页 - * - wap1.2 wap1.2页面 - * - wap2.0 wap2.0页面 - * - js js-sdk 专用 授权页面是弹窗,返回结果为js-sdk回掉函数 + * @param string $display 授权页面类型 可选范围: + * - default 默认授权页面 + * - mobile 支持html5的手机 + * - popup 弹窗授权页 + * - wap1.2 wap1.2页面 + * - wap2.0 wap2.0页面 + * - js js-sdk 专用 授权页面是弹窗,返回结果为js-sdk回掉函数 * - apponweibo 站内应用专用,站内应用不传display参数,并且response_type为token时,默认使用改display.授权后不会返回access_token,只是输出js刷新站内应用父框架 * @return array */ @@ -213,7 +213,7 @@ function getAccessToken( $type = 'code', $keys ) { * @return array */ function parseSignedRequest($signed_request) { - list($encoded_sig, $payload) = explode('.', $signed_request, 2); + list($encoded_sig, $payload) = explode('.', $signed_request, 2); $sig = self::base64decode($encoded_sig) ; $data = json_decode(self::base64decode($payload), true); if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') return '-1'; @@ -448,7 +448,7 @@ public static function build_http_query_multi($params) { if( in_array($parameter, array('pic', 'image')) && $value{0} == '@' ) { $url = ltrim( $value, '@' ); - $content = self::curl_get_file_contents( $url ); + $content = file_get_contents( $url ); $array = explode( '?', basename( $url ) ); $filename = $array[0]; @@ -467,26 +467,6 @@ public static function build_http_query_multi($params) { $multipartbody .= $endMPboundary; return $multipartbody; } - - /** - * @ignore - */ - public static function curl_get_file_contents($durl) { - $ch = curl_init($durl); - $options = array( - CURLOPT_RETURNTRANSFER => true, - CURLOPT_FOLLOWLOCATION => true, // redirects - CURLOPT_USERAGENT => "Sina App Engine", - CURLOPT_AUTOREFERER => true, - CURLOPT_CONNECTTIMEOUT => 120, - CURLOPT_TIMEOUT => 120, - CURLOPT_MAXREDIRS => 10, - ); - curl_setopt_array( $ch, $options ); - $r = curl_exec($ch); - curl_close($ch); - return $r; - } } @@ -503,7 +483,7 @@ class SaeTClientV2 { /** * 构造函数 - * + * * @access public * @param mixed $akey 微博开放平台应用APP KEY * @param mixed $skey 微博开放平台应用APP SECRET @@ -574,7 +554,7 @@ function public_timeline( $page = 1, $count = 50, $base_app = 0 ) * * 获取当前登录用户及其所关注用户的最新微博消息。和用户登录 http://weibo.com 后在“我的首页”中看到的内容相同。同friends_timeline() *
对应API:{@link http://open.weibo.com/wiki/2/statuses/home_timeline statuses/home_timeline} - * + * * @access public * @param int $page 指定返回结果的页码。根据当前登录用户所关注的用户数及这些被关注用户发表的微博数,翻页功能最多能查看的总记录数会有所不同,通常最多能查看1000条左右。默认值1。可选。 * @param int $count 每次返回的记录数。缺省值50,最大值200。可选。 @@ -608,7 +588,7 @@ function home_timeline( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $bas * * 获取当前登录用户及其所关注用户的最新微博消息。和用户登录 http://weibo.com 后在“我的首页”中看到的内容相同。同home_timeline() *
对应API:{@link http://open.weibo.com/wiki/2/statuses/friends_timeline statuses/friends_timeline} - * + * * @access public * @param int $page 指定返回结果的页码。根据当前登录用户所关注的用户数及这些被关注用户发表的微博数,翻页功能最多能查看的总记录数会有所不同,通常最多能查看1000条左右。默认值1。可选。 * @param int $count 每次返回的记录数。缺省值50,最大值200。可选。 @@ -628,7 +608,7 @@ function friends_timeline( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $ * * 返回用户的发布的最近n条信息,和用户微博页面返回内容是一致的。此接口也可以请求其他用户的最新发表微博。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/user_timeline statuses/user_timeline} - * + * * @access public * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 @@ -660,16 +640,16 @@ function user_timeline_by_id( $uid = NULL , $page = 1 , $count = 50 , $since_id return $this->oauth->get( 'statuses/user_timeline', $params ); } - - + + /** * 获取用户发布的微博信息列表 * * 返回用户的发布的最近n条信息,和用户微博页面返回内容是一致的。此接口也可以请求其他用户的最新发表微博。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/user_timeline statuses/user_timeline} - * + * * @access public - * @param string $screen_name 微博昵称,主要是用来区分用户UID跟微博昵称,当二者一样而产生歧义的时候,建议使用该参数 + * @param string $screen_name 微博昵称,主要是用来区分用户UID跟微博昵称,当二者一样而产生歧义的时候,建议使用该参数 * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 * @param int $since_id 若指定此参数,则只返回ID比since_id大的微博消息(即比since_id发表时间晚的微博消息)。可选。 @@ -699,9 +679,9 @@ function user_timeline_by_name( $screen_name = NULL , $page = 1 , $count = 50 , return $this->oauth->get( 'statuses/user_timeline', $params ); } - - - + + + /** * 批量获取指定的一批用户的timeline * @@ -709,7 +689,7 @@ function user_timeline_by_name( $screen_name = NULL , $page = 1 , $count = 50 , * * @param string $screen_name 需要查询的用户昵称,用半角逗号分隔,一次最多20个 * @param int $count 单页返回的记录条数,默认为50。 - * @param int $page 返回结果的页码,默认为1。 + * @param int $page 返回结果的页码,默认为1。 * @param int $base_app 是否只获取当前应用的数据。0为否(所有数据),1为是(仅当前应用),默认为0。 * @param int $feature 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。 * @return array @@ -723,7 +703,7 @@ function timeline_batch_by_name( $screen_name, $page = 1, $count = 50, $feature $params['screen_name'] = $screen_name; } $params['count'] = intval($count); - $params['page'] = intval($page); + $params['page'] = intval($page); $params['base_app'] = intval($base_app); $params['feature'] = intval($feature); return $this->oauth->get('statuses/timeline_batch', $params); @@ -736,7 +716,7 @@ function timeline_batch_by_name( $screen_name, $page = 1, $count = 50, $feature * * @param string $uids 需要查询的用户ID,用半角逗号分隔,一次最多20个。 * @param int $count 单页返回的记录条数,默认为50。 - * @param int $page 返回结果的页码,默认为1。 + * @param int $page 返回结果的页码,默认为1。 * @param int $base_app 是否只获取当前应用的数据。0为否(所有数据),1为是(仅当前应用),默认为0。 * @param int $feature 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。 * @return array @@ -753,7 +733,7 @@ function timeline_batch_by_id( $uids, $page = 1, $count = 50, $feature = 0, $bas $params['uids'] = $uids; } $params['count'] = intval($count); - $params['page'] = intval($page); + $params['page'] = intval($page); $params['base_app'] = intval($base_app); $params['feature'] = intval($feature); return $this->oauth->get('statuses/timeline_batch', $params); @@ -761,13 +741,13 @@ function timeline_batch_by_id( $uids, $page = 1, $count = 50, $feature = 0, $bas /** - * 返回一条原创微博消息的最新n条转发微博消息。本接口无法对非原创微博进行查询。 + * 返回一条原创微博消息的最新n条转发微博消息。本接口无法对非原创微博进行查询。 * * 对应API:{@link http://open.weibo.com/wiki/2/statuses/repost_timeline statuses/repost_timeline} - * + * * @access public * @param int $sid 要获取转发微博列表的原创微博ID。 - * @param int $page 返回结果的页码。 + * @param int $page 返回结果的页码。 * @param int $count 单页返回的最大记录数,最多返回200条,默认50。可选。 * @param int $since_id 若指定此参数,则只返回ID比since_id大的记录(比since_id发表时间晚)。可选。 * @param int $max_id 若指定此参数,则返回ID小于或等于max_id的记录。可选。 @@ -797,9 +777,9 @@ function repost_timeline( $sid, $page = 1, $count = 50, $since_id = 0, $max_id = * 获取当前用户最新转发的n条微博消息 * * 对应API:{@link http://open.weibo.com/wiki/2/statuses/repost_by_me statuses/repost_by_me} - * + * * @access public - * @param int $page 返回结果的页码。 + * @param int $page 返回结果的页码。 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。可选。 * @param int $since_id 若指定此参数,则只返回ID比since_id大的记录(比since_id发表时间晚)。可选。 * @param int $max_id 若指定此参数,则返回ID小于或等于max_id的记录。可选。 @@ -825,7 +805,7 @@ function repost_by_me( $page = 1, $count = 50, $since_id = 0, $max_id = 0 ) * * 返回最新n条提到登录用户的微博消息(即包含@username的微博消息) *
对应API:{@link http://open.weibo.com/wiki/2/statuses/mentions statuses/mentions} - * + * * @access public * @param int $page 返回结果的页序号。 * @param int $count 每次返回的最大记录数(即页面大小),不大于200,默认为50。 @@ -860,7 +840,7 @@ function mentions( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $filter_b * * 获取单条ID的微博信息,作者信息将同时返回。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/show statuses/show} - * + * * @access public * @param int $id 要获取已发表的微博ID, 如ID不存在返回空 * @return array @@ -1011,7 +991,7 @@ function comments_weekly( $count = 20, $base_app = 0) * * 可加评论。为防止重复,发布的信息与最新信息一样话,将会被忽略。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/repost statuses/repost} - * + * * @access public * @param int $sid 转发的微博ID * @param string $text 添加的评论信息。可选。 @@ -1032,10 +1012,10 @@ function repost( $sid, $text = NULL, $is_comment = 0 ) /** * 删除一条微博 - * + * * 根据ID删除微博消息。注意:只能删除自己发布的信息。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/destroy statuses/destroy} - * + * * @access public * @param int $id 要删除的微博ID * @return array @@ -1050,7 +1030,7 @@ function delete( $id ) * * 删除微博。注意:只能删除自己发布的信息。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/destroy statuses/destroy} - * + * * @access public * @param int $id 要删除的微博ID * @return array @@ -1063,15 +1043,15 @@ function destroy( $id ) return $this->oauth->post( 'statuses/destroy', $params ); } - + /** * 发表微博 * * 发布一条微博信息。 *
注意:lat和long参数需配合使用,用于标记发表微博消息时所在的地理位置,只有用户设置中geo_enabled=true时候地理位置信息才有效。 - *
注意:为防止重复提交,当用户发布的微博消息与上次成功发布的微博消息内容一样时,将返回400错误,给出错误提示:“40025:Error: repeated weibo text!“。 + *
注意:为防止重复提交,当用户发布的微博消息与上次成功发布的微博消息内容一样时,将返回400错误,给出错误提示:“40025:Error: repeated weibo text!“。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/update statuses/update} - * + * * @access public * @param string $status 要更新的微博信息。信息内容不超过140个汉字, 为空返回400错误。 * @param float $lat 纬度,发表当前微博所在的地理位置,有效范围 -90.0到+90.0, +表示北纬。可选。 @@ -1101,10 +1081,10 @@ function update( $status, $lat = NULL, $long = NULL, $annotations = NULL ) /** * 发表图片微博 * - * 发表图片微博消息。目前上传图片大小限制为<5M。 + * 发表图片微博消息。目前上传图片大小限制为<5M。 *
注意:lat和long参数需配合使用,用于标记发表微博消息时所在的地理位置,只有用户设置中geo_enabled=true时候地理位置信息才有效。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/upload statuses/upload} - * + * * @access public * @param string $status 要更新的微博信息。信息内容不超过140个汉字, 为空返回400错误。 * @param string $pic_path 要发布的图片路径, 支持url。[只支持png/jpg/gif三种格式, 增加格式请修改get_image_mime方法] @@ -1134,15 +1114,38 @@ function upload( $status, $pic_path, $lat = NULL, $long = NULL ) * 对应API:{@link http://open.weibo.com/wiki/2/statuses/upload_url_text statuses/upload_url_text} * * @param string $status 要发布的微博文本内容,内容不超过140个汉字。 + * @param int $visible 微博的可见性,0:所有人能看,1:仅自己可见,2:密友可见,3:指定分组可见,默认为0 + * @param string $list_id 微博的保护投递指定分组ID,只有当visible参数为3时生效且必选。 + * @param string $pic_id 已经上传的图片pid,多个时使用英文半角逗号符分隔,最多不超过9个。 + * @param float $lat 纬度,有效范围:-90.0到+90.0,+表示北纬,默认为0.0。 + * @param float $long 经度,有效范围:-180.0到+180.0,+表示东经,默认为0.0。 + * @param string $annotations 元数据,主要是为了方便第三方应用记录一些适合于自己使用的信息,每条微博可以包含一个或者多个元数据, + * 必须以json字串的形式提交,字串长度不超过512个字符,具体内容可以自定。 * @param string $url 图片的URL地址,必须以http开头。 * @return array */ - function upload_url_text( $status, $url ) + function upload_url_text( $status, $url , $visible=0, $list_id=NULL, $pic_id=NULL, $lat = NULL, $long=NULL, $annotations=NULL) { $params = array(); $params['status'] = $status; $params['url'] = $url; - return $this->oauth->post( 'statuses/upload', $params, true ); + $params['visible'] = $visible; + if (!is_null($list_id)) { + $params['list_id'] = $list_id; + } + if (!is_null($pic_id)) { + $params['pic_id'] = $pic_id; + } + if (!is_null($lat)) { + $params['lat'] = $lat; + } + if (!is_null($long)) { + $params['long'] = $long; + } + if (!is_null($annotations)) { + $params['annotations'] = $annotations; + } + return $this->oauth->post( 'statuses/upload_url_text', $params, true ); } @@ -1151,7 +1154,7 @@ function upload_url_text( $status, $url ) * * 返回新浪微博官方所有表情、魔法表情的相关信息。包括短语、表情类型、表情分类,是否热门等。 *
对应API:{@link http://open.weibo.com/wiki/2/emotions emotions} - * + * * @access public * @param string $type 表情类别。"face":普通表情,"ani":魔法表情,"cartoon":动漫表情。默认为"face"。可选。 * @param string $language 语言类别,"cnname"简体,"twname"繁体。默认为"cnname"。可选 @@ -1240,7 +1243,7 @@ function comments_by_me( $page = 1 , $count = 50, $since_id = 0, $max_id = 0, $ * @param int $filter_by_author 作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。 * @param int $filter_by_source 来源筛选类型,0:全部、1:来自微博的评论、2:来自微群的评论,默认为0。 * @return array - */ + */ function comments_to_me( $page = 1 , $count = 50, $since_id = 0, $max_id = 0, $filter_by_author = 0, $filter_by_source = 0) { $params = array(); @@ -1264,7 +1267,7 @@ function comments_to_me( $page = 1 , $count = 50, $since_id = 0, $max_id = 0, $f * * 返回最新n条发送及收到的评论。 *
对应API:{@link http://open.weibo.com/wiki/2/comments/timeline comments/timeline} - * + * * @access public * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 @@ -1300,7 +1303,7 @@ function comments_timeline( $page = 1, $count = 50, $since_id = 0, $max_id = 0 ) * @param int $filter_by_author 作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。 * @param int $filter_by_source 来源筛选类型,0:全部、1:来自微博的评论、2:来自微群的评论,默认为0。 * @return array - */ + */ function comments_mentions( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $filter_by_author = 0, $filter_by_source = 0) { $params = array(); @@ -1362,7 +1365,7 @@ function send_comment( $id , $comment , $comment_ori = 0) * * 注意:只能删除自己发布的评论,发部微博的用户不可以删除其他人的评论。 *
对应API:{@link http://open.weibo.com/wiki/2/statuses/comment_destroy statuses/comment_destroy} - * + * * @access public * @param int $cid 要删除的评论id * @return array @@ -1405,7 +1408,7 @@ function comment_destroy_batch( $ids ) * * 为防止重复,发布的信息与最后一条评论/回复信息一样话,将会被忽略。 *
对应API:{@link http://open.weibo.com/wiki/2/comments/reply comments/reply} - * + * * @access public * @param int $sid 微博id * @param string $text 评论内容。 @@ -1434,7 +1437,7 @@ function reply( $sid, $text, $cid, $without_mention = 0, $comment_ori = 0 ) * * 按用户UID或昵称返回用户资料,同时也将返回用户的最新发布的微博。 *
对应API:{@link http://open.weibo.com/wiki/2/users/show users/show} - * + * * @access public * @param int $uid 用户UID。 * @return array @@ -1449,13 +1452,13 @@ function show_user_by_id( $uid ) return $this->oauth->get('users/show', $params ); } - + /** * 根据用户UID或昵称获取用户资料 * * 按用户UID或昵称返回用户资料,同时也将返回用户的最新发布的微博。 *
对应API:{@link http://open.weibo.com/wiki/2/users/show users/show} - * + * * @access public * @param string $screen_name 用户UID。 * @return array @@ -1468,31 +1471,11 @@ function show_user_by_name( $screen_name ) return $this->oauth->get( 'users/show', $params ); } - - /** - * 根据长链接获取短链 - * - * 根据长链接获取短链返地址。 - *
对应API:{@link http://open.weibo.com/wiki/2/short_url/shorten} - * - * @access public - * @param string $url 长链接地址。 - * @return array - */ - function get_short_url( $url ) - { - $params=array(); - if ( $url !== NULL ) { - $params['url_long'] = $url; - } - return $this->oauth->get( 'short_url/shorten', $params); - } - /** * 通过个性化域名获取用户资料以及用户最新的一条微博 * * 对应API:{@link http://open.weibo.com/wiki/2/users/domain_show users/domain_show} - * + * * @access public * @param mixed $domain 用户个性域名。例如:lazypeople,而不是http://weibo.com/lazypeople * @return array @@ -1525,7 +1508,7 @@ function users_show_batch_by_id( $uids ) } return $this->oauth->get( 'users/show_batch', $params ); } - + /** * 批量获取用户信息按screen_name * @@ -1551,7 +1534,7 @@ function users_show_batch_by_name( $screen_name ) * * 如果没有提供cursor参数,将只返回最前面的5000个关注id *
对应API:{@link http://open.weibo.com/wiki/2/friendships/friends friendships/friends} - * + * * @access public * @param int $cursor 返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。 * @param int $count 单页返回的记录条数,默认为50,最大不超过200。 @@ -1567,14 +1550,14 @@ function friends_by_id( $uid, $cursor = 0, $count = 50 ) return $this->oauth->get( 'friendships/friends', $params ); } - - + + /** * 获取用户的关注列表 * * 如果没有提供cursor参数,将只返回最前面的5000个关注id *
对应API:{@link http://open.weibo.com/wiki/2/friendships/friends friendships/friends} - * + * * @access public * @param int $cursor 返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。 * @param int $count 单页返回的记录条数,默认为50,最大不超过200。 @@ -1659,7 +1642,7 @@ function bilateral_ids( $uid, $page = 1, $count = 50, $sort = 0) * * 如果没有提供cursor参数,将只返回最前面的5000个关注id *
对应API:{@link http://open.weibo.com/wiki/2/friendships/friends/ids friendships/friends/ids} - * + * * @access public * @param int $cursor 返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。 * @param int $count 每次返回的最大记录数(即页面大小),不大于5000, 默认返回500。 @@ -1675,13 +1658,13 @@ function friends_ids_by_id( $uid, $cursor = 0, $count = 500 ) $params['count'] = $count; return $this->oauth->get( 'friendships/friends/ids', $params ); } - + /** * 获取用户的关注列表uid * * 如果没有提供cursor参数,将只返回最前面的5000个关注id *
对应API:{@link http://open.weibo.com/wiki/2/friendships/friends/ids friendships/friends/ids} - * + * * @access public * @param int $cursor 返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。 * @param int $count 每次返回的最大记录数(即页面大小),不大于5000, 默认返回500。 @@ -1739,7 +1722,7 @@ function followers_by_id( $uid , $cursor = 0 , $count = 50) $params['cursor'] = $cursor; return $this->oauth->get( 'friendships/followers', $params ); } - + /** * 获取用户的粉丝列表 * @@ -1778,7 +1761,7 @@ function followers_ids_by_id( $uid, $cursor = 0 , $count = 50 ) $params['cursor'] = $cursor; return $this->oauth->get( 'friendships/followers/ids', $params ); } - + /** * 获取用户的粉丝列表uid * @@ -1842,7 +1825,7 @@ function friends_chain_followers( $uid, $page = 1, $count = 50 ) * * 如果源用户或目的用户不存在,将返回http的400错误 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/show friendships/show} - * + * * @access public * @param mixed $target_id 目标用户UID * @param mixed $source_id 源用户UID,可选,默认为当前的用户 @@ -1867,7 +1850,7 @@ function is_followed_by_id( $target_id, $source_id = NULL ) * * 如果源用户或目的用户不存在,将返回http的400错误 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/show friendships/show} - * + * * @access public * @param mixed $target_name 目标用户的微博昵称 * @param mixed $source_name 源用户的微博昵称,可选,默认为当前的用户 @@ -1890,7 +1873,7 @@ function is_followed_by_name( $target_name, $source_name = NULL ) * * 成功则返回关注人的资料,目前最多关注2000人,失败则返回一条字符串的说明。如果已经关注了此人,则返回http 403的状态。关注不存在的ID将返回400。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/create friendships/create} - * + * * @access public * @param int $uid 要关注的用户UID * @return array @@ -1902,13 +1885,13 @@ function follow_by_id( $uid ) $params['uid'] = $uid; return $this->oauth->post( 'friendships/create', $params ); } - + /** * 关注一个用户。 * * 成功则返回关注人的资料,目前的最多关注2000人,失败则返回一条字符串的说明。如果已经关注了此人,则返回http 403的状态。关注不存在的ID将返回400。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/create friendships/create} - * + * * @access public * @param string $screen_name 要关注的用户昵称 * @return array @@ -1948,7 +1931,7 @@ function follow_create_batch( $uids ) * * 取消关注某用户。成功则返回被取消关注人的资料,失败则返回一条字符串的说明。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/destroy friendships/destroy} - * + * * @access public * @param int $uid 要取消关注的用户UID * @return array @@ -1960,13 +1943,13 @@ function unfollow_by_id( $uid ) $params['uid'] = $uid; return $this->oauth->post( 'friendships/destroy', $params); } - + /** * 取消关注某用户 * * 取消关注某用户。成功则返回被取消关注人的资料,失败则返回一条字符串的说明。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/destroy friendships/destroy} - * + * * @access public * @param string $screen_name 要取消关注的用户昵称 * @return array @@ -1983,7 +1966,7 @@ function unfollow_by_name( $screen_name ) * * 只能修改当前登录用户所关注的用户的备注信息。否则将给出400错误。 *
对应API:{@link http://open.weibo.com/wiki/2/friendships/remark/update friendships/remark/update} - * + * * @access public * @param int $uid 需要修改备注信息的用户ID。 * @param string $remark 备注信息。 @@ -2003,7 +1986,7 @@ function update_remark( $uid, $remark ) * * 返回用户的最新n条私信,并包含发送者和接受者的详细资料。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages direct_messages} - * + * * @access public * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 @@ -2031,7 +2014,7 @@ function list_dm( $page = 1, $count = 50, $since_id = 0, $max_id = 0 ) * * 返回登录用户已发送最新50条私信。包括发送者和接受者的详细资料。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/sent direct_messages/sent} - * + * * @access public * @param int $page 页码 * @param int $count 每次返回的最大记录数,最多返回200条,默认50。 @@ -2070,7 +2053,7 @@ function dm_user_list( $count = 20, $cursor = 0) $params['count'] = $count; $params['cursor'] = $cursor; return $this->oauth->get( 'direct_messages/user_list', $params ); - } + } /** * 获取与指定用户的往来私信列表 @@ -2129,7 +2112,7 @@ function dm_show_batch( $dmids ) * * 发送一条私信。成功将返回完整的发送消息。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/new direct_messages/new} - * + * * @access public * @param int $uid 用户UID * @param string $text 要发生的消息内容,文本大小必须小于300个汉字。 @@ -2148,13 +2131,13 @@ function send_dm_by_id( $uid, $text, $id = NULL ) } return $this->oauth->post( 'direct_messages/new', $params ); } - + /** * 发送私信 * * 发送一条私信。成功将返回完整的发送消息。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/new direct_messages/new} - * + * * @access public * @param string $screen_name 用户昵称 * @param string $text 要发生的消息内容,文本大小必须小于300个汉字。 @@ -2178,7 +2161,7 @@ function send_dm_by_name( $screen_name, $text, $id = NULL ) * * 按ID删除私信。操作用户必须为私信的接收人。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/destroy direct_messages/destroy} - * + * * @access public * @param int $did 要删除的私信主键ID * @return array @@ -2196,7 +2179,7 @@ function delete_dm( $did ) * * 批量删除当前登录用户的私信。出现异常时,返回400错误。 *
对应API:{@link http://open.weibo.com/wiki/2/direct_messages/destroy_batch direct_messages/destroy_batch} - * + * * @access public * @param mixed $dids 欲删除的一组私信ID,用半角逗号隔开,或者由一组评论ID组成的数组。最多20个。例如:"4976494627, 4976262053"或array(4976494627,4976262053); * @return array @@ -2215,7 +2198,7 @@ function delete_dms( $dids ) return $this->oauth->post( 'direct_messages/destroy_batch', $params); } - + /** @@ -2323,7 +2306,7 @@ function account_career_batch( $uids ) * 获取隐私信息设置情况 * * 对应API:{@link http://open.weibo.com/wiki/2/account/get_privacy account/get_privacy} - * + * * @access public * @return array */ @@ -2360,7 +2343,7 @@ function school_list( $query ) * 获取当前登录用户的API访问频率限制情况 * * 对应API:{@link http://open.weibo.com/wiki/2/account/rate_limit_status account/rate_limit_status} - * + * * @access public * @return array */ @@ -2373,7 +2356,7 @@ function rate_limit_status() * OAuth授权之后,获取授权用户的UID * * 对应API:{@link http://open.weibo.com/wiki/2/account/get_uid account/get_uid} - * + * * @access public * @return array */ @@ -2387,7 +2370,7 @@ function get_uid() * 更改用户资料 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/basic_update account/profile/basic_update} - * + * * @access public * @param array $profile 要修改的资料。格式:array('key1'=>'value1', 'key2'=>'value2', .....)。 * 支持修改的项: @@ -2427,7 +2410,7 @@ function update_profile( $profile ) * 设置教育信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/edu_update account/profile/edu_update} - * + * * @access public * @param array $edu_update 要修改的学校信息。格式:array('key1'=>'value1', 'key2'=>'value2', .....)。 * 支持设置的项: @@ -2448,7 +2431,7 @@ function edu_update( $edu_update ) * 根据学校ID删除用户的教育信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/edu_destroy account/profile/edu_destroy} - * + * * @param int $id 教育信息里的学校ID。 * @return array */ @@ -2464,7 +2447,7 @@ function edu_destroy( $id ) * 设置职业信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/car_update account/profile/car_update} - * + * * @param array $car_update 要修改的职业信息。格式:array('key1'=>'value1', 'key2'=>'value2', .....)。 * 支持设置的项: * - id string 需要更新的职业信息ID。 @@ -2488,7 +2471,7 @@ function car_update( $car_update ) * 根据公司ID删除用户的职业信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/profile/car_destroy account/profile/car_destroy} - * + * * @access public * @param int $id 职业信息里的公司ID * @return array @@ -2521,7 +2504,7 @@ function update_profile_image( $image_path ) * 设置隐私信息 * * 对应API:{@link http://open.weibo.com/wiki/2/account/update_privacy account/update_privacy} - * + * * @param array $privacy_settings 要修改的隐私设置。格式:array('key1'=>'value1', 'key2'=>'value2', .....)。 * 支持设置的项: * - comment int 是否可以评论我的微博,0:所有人、1:关注的人,默认为0。 @@ -2544,7 +2527,7 @@ function update_privacy( $privacy_settings ) * * 返回用户的发布的最近20条收藏信息,和用户收藏页面返回内容是一致的。 *
对应API:{@link http://open.weibo.com/wiki/2/favorites favorites} - * + * * @access public * @param int $page 返回结果的页码,默认为1。 * @param int $count 单页返回的记录条数,默认为50。 @@ -2565,7 +2548,7 @@ function get_favorites( $page = 1, $count = 50 ) * * 根据收藏ID获取指定的收藏信息。 *
对应API:{@link http://open.weibo.com/wiki/2/favorites/show favorites/show} - * + * * @access public * @param int $id 需要查询的收藏ID。 * @return array @@ -2584,7 +2567,7 @@ function favorites_show( $id ) * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/by_tags favorites/by_tags} * - * + * * @param int $tid 需要查询的标签ID。' * @param int $count 单页返回的记录条数,默认为50。 * @param int $page 返回结果的页码,默认为1。 @@ -2604,7 +2587,7 @@ function favorites_by_tags( $tid, $page = 1, $count = 50) * 获取当前登录用户的收藏标签列表 * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/tags favorites/tags} - * + * * @access public * @param int $count 单页返回的记录条数,默认为50。 * @param int $page 返回结果的页码,默认为1。 @@ -2623,7 +2606,7 @@ function favorites_tags( $page = 1, $count = 50) * 收藏一条微博信息 * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/create favorites/create} - * + * * @access public * @param int $sid 收藏的微博id * @return array @@ -2641,7 +2624,7 @@ function add_to_favorites( $sid ) * 删除微博收藏。 * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/destroy favorites/destroy} - * + * * @access public * @param int $id 要删除的收藏微博信息ID. * @return array @@ -2660,7 +2643,7 @@ function remove_from_favorites( $id ) * * 批量删除当前登录用户的收藏。出现异常时,返回HTTP400错误。 *
对应API:{@link http://open.weibo.com/wiki/2/favorites/destroy_batch favorites/destroy_batch} - * + * * @access public * @param mixed $fids 欲删除的一组私信ID,用半角逗号隔开,或者由一组评论ID组成的数组。最多20个。例如:"231101027525486630,201100826122315375"或array(231101027525486630,201100826122315375); * @return array @@ -2685,7 +2668,7 @@ function remove_from_favorites_batch( $fids ) * 更新一条收藏的收藏标签 * * 对应API:{@link http://open.weibo.com/wiki/2/favorites/tags/update favorites/tags/update} - * + * * @access public * @param int $id 需要更新的收藏ID。 * @param string $tags 需要更新的标签内容,用半角逗号分隔,最多不超过2条。 @@ -2743,7 +2726,7 @@ function favorites_tags_destroy_batch( $tid ) * 获取某用户的话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends trends} - * + * * @param int $uid 查询用户的ID。默认为当前用户。可选。 * @param int $page 指定返回结果的页码。可选。 * @param int $count 单页大小。缺省值10。可选。 @@ -2769,7 +2752,7 @@ function get_trends( $uid = NULL, $page = 1, $count = 10 ) * 判断当前用户是否关注某话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/is_follow trends/is_follow} - * + * * @access public * @param string $trend_name 话题关键字。 * @return array @@ -2785,7 +2768,7 @@ function trends_is_follow( $trend_name ) * 返回最近一小时内的热门话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/hourly trends/hourly} - * + * * @param int $base_app 是否基于当前应用来获取数据。1表示基于当前应用来获取数据,默认为0。可选。 * @return array */ @@ -2801,7 +2784,7 @@ function hourly_trends( $base_app = 0 ) * 返回最近一天内的热门话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/daily trends/daily} - * + * * @param int $base_app 是否基于当前应用来获取数据。1表示基于当前应用来获取数据,默认为0。可选。 * @return array */ @@ -2817,7 +2800,7 @@ function daily_trends( $base_app = 0 ) * 返回最近一周内的热门话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/weekly trends/weekly} - * + * * @access public * @param int $base_app 是否基于当前应用来获取数据。1表示基于当前应用来获取数据,默认为0。可选。 * @return array @@ -2834,7 +2817,7 @@ function weekly_trends( $base_app = 0 ) * 关注某话题 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/follow trends/follow} - * + * * @access public * @param string $trend_name 要关注的话题关键词。 * @return array @@ -2850,7 +2833,7 @@ function follow_trends( $trend_name ) * 取消对某话题的关注 * * 对应API:{@link http://open.weibo.com/wiki/2/trends/destroy trends/destroy} - * + * * @access public * @param int $tid 要取消关注的话题ID。 * @return array @@ -2869,7 +2852,7 @@ function unfollow_trends( $tid ) * 返回指定用户的标签列表 * * 对应API:{@link http://open.weibo.com/wiki/2/tags tags} - * + * * @param int $uid 查询用户的ID。默认为当前用户。可选。 * @param int $page 指定返回结果的页码。可选。 * @param int $count 单页大小。缺省值20,最大值200。可选。 @@ -2894,7 +2877,7 @@ function get_tags( $uid = NULL, $page = 1, $count = 20 ) * 批量获取用户的标签列表 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/tags_batch tags/tags_batch} - * + * * @param string $uids 要获取标签的用户ID。最大20,逗号分隔。必填 * @return array */ @@ -2916,7 +2899,7 @@ function get_tags_batch( $uids ) * 返回用户感兴趣的标签 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/suggestions tags/suggestions} - * + * * @access public * @param int $count 单页大小。缺省值10,最大值10。可选。 * @return array @@ -2932,7 +2915,7 @@ function get_suggest_tags( $count = 10) * 为当前登录用户添加新的用户标签 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/create tags/create} - * + * * @access public * @param mixed $tags 要创建的一组标签,每个标签的长度不可超过7个汉字,14个半角字符。多个标签之间用逗号间隔,或由多个标签构成的数组。如:"abc,drf,efgh,tt"或array("abc", "drf", "efgh", "tt") * @return array @@ -2952,7 +2935,7 @@ function add_tags( $tags ) * 删除标签 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/destroy tags/destroy} - * + * * @access public * @param int $tag_id 标签ID,必填参数 * @return array @@ -2968,7 +2951,7 @@ function delete_tag( $tag_id ) * 批量删除标签 * * 对应API:{@link http://open.weibo.com/wiki/2/tags/destroy_batch tags/destroy_batch} - * + * * @access public * @param mixed $ids 必选参数,要删除的tag id,多个id用半角逗号分割,最多10个。或由多个tag id构成的数组。如:“553,554,555"或array(553, 554, 555) * @return array @@ -3097,7 +3080,7 @@ function search_at_users( $q, $count = 10, $type=0, $range = 2) } - + /** @@ -3163,7 +3146,7 @@ function search_users_keywords( $query ) * * 返回系统推荐的用户列表。 *
对应API:{@link http://open.weibo.com/wiki/2/suggestions/users/hot suggestions/users/hot} - * + * * @access public * @param string $category 分类,可选参数,返回某一类别的推荐用户,默认为 default。如果不在以下分类中,返回空列表:
* - default:人气关注 @@ -3193,7 +3176,7 @@ function hot_users( $category = "default" ) * 获取用户可能感兴趣的人 * * 对应API:{@link http://open.weibo.com/wiki/2/suggestions/users/may_interested suggestions/users/may_interested} - * + * * @access public * @param int $page 返回结果的页码,默认为1。 * @param int $count 单页返回的记录条数,默认为10。 @@ -3201,7 +3184,7 @@ function hot_users( $category = "default" ) * @ignore */ function suggestions_may_interested( $page = 1, $count = 10 ) - { + { $params = array(); $params['page'] = $page; $params['count'] = $count; @@ -3209,10 +3192,10 @@ function suggestions_may_interested( $page = 1, $count = 10 ) } /** - * 根据一段微博正文推荐相关微博用户。 + * 根据一段微博正文推荐相关微博用户。 * * 对应API:{@link http://open.weibo.com/wiki/2/suggestions/users/by_status suggestions/users/by_status} - * + * * @access public * @param string $content 微博正文内容。 * @param int $num 返回结果数目,默认为10。 From 1a312eafd63249cc1c7d797c33eb6dcf4bed4aff Mon Sep 17 00:00:00 2001 From: Lazypeople Date: Wed, 7 Aug 2013 11:18:03 +0800 Subject: [PATCH 06/11] README modify --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a8abe36..92b14cd 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ 用于新浪微博开放平台的PHP SDK. 内含能直接使用的DEMO. -SAE(Sina App Engine, http://sae.sina.com.cn )已内置SDK,不需要下载 +SAE(Sina App Engine, http://sae.sina.com.cn )已内置SDK,不需要下载,使用前需要手工调用 require_once('saetv2.ex.class.php'); 更新 @@ -67,7 +67,7 @@ Authors ------- + http://weibo.com/lazypeople -+ http://skirt.sinaapp.com ++ http://lazy.changes.com.cn License From 83bcc8ee3b405caf43954f9c9569ce573fb6357c Mon Sep 17 00:00:00 2001 From: mingming6 Date: Mon, 30 Dec 2013 16:46:40 +0800 Subject: [PATCH 07/11] Fix curl warning caused by php version --- saetv2.ex.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/saetv2.ex.class.php b/saetv2.ex.class.php index 506eb03..e6752e6 100644 --- a/saetv2.ex.class.php +++ b/saetv2.ex.class.php @@ -354,7 +354,11 @@ function http($url, $method, $postfields = NULL, $headers = array()) { curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ci, CURLOPT_ENCODING, ""); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer); - curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, 1); + if (version_compare(phpversion(), '5.4.0', '<')) { + curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, 1); + } else { + curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, 2); + } curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader')); curl_setopt($ci, CURLOPT_HEADER, FALSE); From 13ec34faef2fdaa2080b70821415cf6116a93d70 Mon Sep 17 00:00:00 2001 From: mingming6 Date: Mon, 9 Mar 2015 12:09:21 +0800 Subject: [PATCH 08/11] Fix update_profile_image bug --- saetv2.ex.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saetv2.ex.class.php b/saetv2.ex.class.php index e6752e6..d4dc167 100644 --- a/saetv2.ex.class.php +++ b/saetv2.ex.class.php @@ -2501,7 +2501,7 @@ function update_profile_image( $image_path ) $params = array(); $params['image'] = "@{$image_path}"; - return $this->oauth->post('account/avatar/upload', $params); + return $this->oauth->post('account/avatar/upload', $params, true); } /** From 3507bf43d9e7132b53ee3509fa505c163ab05d22 Mon Sep 17 00:00:00 2001 From: mingming6 Date: Thu, 26 Mar 2015 10:31:58 +0800 Subject: [PATCH 09/11] Add composer --- composer.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..c19203f --- /dev/null +++ b/composer.json @@ -0,0 +1,22 @@ +{ + "name": "xiaosier/libweibo", + "type": "library", + "description": "PHP sdk for Weibo open platform", + "keywords": ["sdk","weibo"], + "homepage": "http://github.com/xiaosier/libweibo", + "license": "MIT", + "authors": [ + { + "name": "lazypeople", + "email": "hfutming@gmail.com", + "homepage": "http://lazy.changes.com.cn", + "role": "Developer" + } + ], + "require": { + "php": ">=5.0.0" + }, + "autoload": { + "files": ["saetv2.ex.class.php"] + } +} \ No newline at end of file From 61be700cd15f4c53496b998c8ae8fdd73084eb38 Mon Sep 17 00:00:00 2001 From: mingming6 Date: Thu, 26 Mar 2015 11:17:59 +0800 Subject: [PATCH 10/11] Update readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 92b14cd..03eb3e9 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ SAE(Sina App Engine, http://sae.sina.com.cn )已内置SDK,不需要下载,使用前需要手工调用 require_once('saetv2.ex.class.php'); +composer +----- +composer.phar require xiaosier/libweibo:dev-master 更新 ----- From 7501b46988c40876076b27996cdd9171e5b1cea1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Jul 2015 12:35:53 +0800 Subject: [PATCH 11/11] friends_timeline params --- saetv2.ex.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saetv2.ex.class.php b/saetv2.ex.class.php index d4dc167..43e6852 100644 --- a/saetv2.ex.class.php +++ b/saetv2.ex.class.php @@ -604,7 +604,7 @@ function home_timeline( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $bas */ function friends_timeline( $page = 1, $count = 50, $since_id = 0, $max_id = 0, $base_app = 0, $feature = 0 ) { - return $this->home_timeline( $since_id, $max_id, $count, $page, $base_app, $feature); + return $this->home_timeline($page, $count, $since_id, $max_id, $base_app, $feature); } /**