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)

Supported Formats

XML/JSON

HTTP Request Method

GET

Requires Authentication

true
See the Authorization Mechanism Statement for authorization details

Requests Count Limitation

true
See the Interface Access Rights Statement for the Request Count Limitaiton details.

Request Parameters

  Requires Type and Range Description
source true string AppKey for the application to identify it. ( This parameter is not needed when using 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.

Notes

  • 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";
		}
	}
}

Example Request

XML
curl -u "username:password" "http://api.t.sina.com.cn/friendships/show.xml?source=appkey&target_id=456"
JSON
curl -u "username:password" "http://api.t.sina.com.cn/friendships/show.json?source=appkey&target_id=456"

Response

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
   }
 }

Others

{{{otherInfo}}}