返回最新n条提到登录用户的微博消息(即包含@username的微博消息)
对应API:{@link http://open.weibo.com/wiki/2/statuses/mentions statuses/mentions}
对应API:{@link http://open.weibo.com/wiki/2/statuses/mentions statuses/mentions}
public mentions ( integer $page = 1, integer $count = 50, integer $since_id, integer $max_id, integer $filter_by_author, integer $filter_by_source, integer $filter_by_type ) : array | ||
$page | integer | 返回结果的页序号。 |
$count | integer | 每次返回的最大记录数(即页面大小),不大于200,默认为50。 |
$since_id | integer | 若指定此参数,则只返回ID比since_id大的微博消息(即比since_id发表时间晚的微博消息)。可选。 |
$max_id | integer | 若指定此参数,则返回ID小于或等于max_id的提到当前登录用户微博消息。可选。 |
$filter_by_author | integer | 作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。 |
$filter_by_source | integer | 来源筛选类型,0:全部、1:来自微博、2:来自微群,默认为0。 |
$filter_by_type | integer | 原创筛选类型,0:全部微博、1:原创的微博,默认为0。 |
return | array |
$o = new SaeTOAuthV2(WB_AKEY, WB_SKEY); $keys = array(); $keys['username'] = $_REQUEST['username']; $keys['password'] = $_REQUEST['password']; try { $token = $o->getAccessToken('password', $keys); } catch (OAuthException $e) { echo json_encode(array('error' => $e->getMessage())); } if ($token) { $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $token['access_token']); //如果Post中带有since_id if (is_numeric($_REQUEST['since_id']) && !empty($_REQUEST['since_id'])) { //获得比since_id更晚的mention //API:{@link http://open.weibo.com/wiki/2/statuses/mentions statuses/mentions} $atme = $c->mentions(1, NULL, $_REQUEST['since_id'], 0); } else { //没有since_id $atme = $c->mentions(1, NULL, NULL, 0); } //若指定since_id,倒序排列获得的mentions数组,第一组即是since_id的后一条 //若未指定since_id,就不用倒序,直接获取最新一条 if (is_numeric($_REQUEST['since_id']) && !empty($_REQUEST['since_id'])) { rsort($atme[statuses], SORT_STRING); } if (isset($atme[error])) { echo json_encode($atme); } else { if (isset($atme[statuses][0])) { //构造json $new_atme = array('id' => $atme[statuses][0][id], 'text' => $atme[statuses][0][text], 'uid' => $atme[statuses][0][user][id], 'user' => $atme[statuses][0][user][screen_name]);