Friendships/show/en

跳转到: 导航, 搜索

目录

friendships/show

Returns the details about the following status between two users.

URL

http://api.t.sina.com.cn/friendships/show.(json%7Cxml)

支持格式

XML/JSON

HTTP请求方式

GET

是否需要登录

true
关于授权机制,参见授权机制声明

请求数限制

true
关于请求数限制,参见接口访问权限说明

请求参数

  必选 类型及范围 说明
source true string 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。(采用OAuth授权方式不需要此参数)
The following parameters are not required. If left empty, the default user is theauthenticating user.
source_id false int64 the user_id of the subject user.
source_screen_name false string screen name of the subject user.
One of the following is required.
target_id false int64 The user_id of the target user.
target_screen_name false string The screen name of the target user.

注意事项

  • If current user is authenticated, this API will automaticly treat the current user’s ID as source_id. But it can be assigned a different user id by by force to test the relationship.
  • It returns HTTP 400 error, if the subject or target user does not exist,
  • <blocking> means whether the source user is blocking the target user. Available only when source_id is current user, that is user can only view his own blockings. ( blocking protocol temporarily does not support return.)

otherInfo=

=PHP Example

Please download PHP SDK with OAUTH supported from Weibo SDK Development Kit Dowload Site
. Sample Code:

//Friendships/show
$c = new WeiboClient( WB_AKEY , 
                      WB_SKEY , 
                      $_SESSION['last_key']['oauth_token'] , 
                      $_SESSION['last_key']['oauth_token_secret']  );

//关注对象的id
$u_id = "u_id";
$msg = $c->is_followed($u_id);
if ($msg === false || $msg === null){
	echo "Error occured";
	return false;
}
if (isset($msg['error_code']) && isset($msg['error'])){
	echo ('Error_code: '.$msg['error_code'].';  Error: '.$msg['error'] );
	return false;
}
if (isset($msg['target'])){
	if (isset($msg['target']['followed_by'])){
		if ($msg['target']['followed_by'] === true){
			echo "Target is followed: true";
		} else {
			echo "Target is followed: false";
		}
	}
}

返回结果

XML Example

<?xml version="1.0" encoding="UTF-8"?>
 <relationship>
 <source>
 <id>123</id>
 <screen_name>bob</screen_name>
 <following>true</following>
 <followed_by>false</followed_by>
 <notifications_enabled>false</notifications_enabled>
 </source>
 <target>
 <id>456</id>
 <screen_name>jack</screen_name>
 <following>false</following>
 <followed_by>true</followed_by>
 <notifications_enabled></notifications_enabled>
 </target>
 </relationship>

JSON Example

  {
     "source":{
         "id":245110499
         ,"screen_name":"245110499"
         ,"following":false
         ,"followed_by":false
         ,"notifications_enabled":false
    }
    ,"target":{
         "id":10503      
         ,"screen_name":"10503"
         ,"following":false
         ,"followed_by":false
         ,"notifications_enabled":false
   }
 }

其他

{{{otherInfo}}}