Friendships provide visible connections between community participants. With this endpoint, you can get details of all friendship requests for a specific user.
EndpointGETapi.ashx/v2/users/{requestorname}/friends/pending.xml (or .json)
EndpointGETapi.ashx/v2/users/{requestorid}/friends/pending.xml (or .json)
RequestFriendshipListRequest
| RequestorId |
Optional |
Either the RequestorId or the RequestorName is required. |
| RequestorName |
Optional |
Either the RequestorId or the RequestorName is required. |
| RequesteeId |
Optional |
RequesteeId |
| FriendshipState |
Optional |
Defaults to Approved. Other options are Pending and NotSpecified. |
| PageSize |
Optional |
Specify the number of results to return per page. If not set the default is 20. The max is 100. |
| PageIndex |
Optional |
Specify the page number of paged results to return. Zero-based index. If not specified the default is 0. |
Example (C#)
var webClient = new WebClient();
// replace the "admin" and "Admin's API key" with your valid user and apikey!
// http://telligent.com/community/developers/w/wiki/how-to-generate-an-api-key.aspx
var adminKey = String.Format("{0}:{1}", "Admin's API Key", "admin");
var adminKeyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(adminKey));
webClient.Headers.Add("Rest-User-Token", adminKeyBase64);
var requestUrl = "http://mysite.com/api.ashx/v2/users/2100/friends/pending.xml"; // or .json
var xml = webClient.DownloadString(requestUrl);
Console.WriteLine(xml);
Example Response (XML)
<?xml version="1.0" encoding="utf-8"?>
<Response>
<Info />
<Warnings />
<Errors />
<Friendships PageSize="20" PageIndex="0" TotalCount="1">
<Friendship>
<Id>813</Id>
<CreatedDate>2011-02-15T09:21:00.537</CreatedDate>
<FriendshipState>Pending</FriendshipState>
<LastModifiedDate>2011-02-15T09:21:00.537</LastModifiedDate>
<RequestMessage>Please be my friend!</RequestMessage>
<RequestorId>39609</RequestorId>
<RequesteeId>2100</RequesteeId>
<User>
<Id>39609</Id>
<AvatarUrl>http://localhost/cs/utility/anonymous.gif</AvatarUrl>
<DisplayName>danb</DisplayName>
<ProfileUrl>http://localhost/cs/members/danb/default.aspx</ProfileUrl>
<Username>danb</Username>
</User>
</Friendship>
</Friendships>
</Response>
Example Response (JSON)
{
"PageSize": 20,
"PageIndex": 0,
"TotalCount": 1,
"Friendships": [
{
"CreatedDate": "\/Date(1297779660537-0500)\/",
"FriendshipState": 1,
"LastModifiedDate": "\/Date(1297779660537-0500)\/",
"RequestMessage": "Please be my friend!",
"RequestorId": 39609,
"RequesteeId": 2100,
"User": {
"AvatarUrl": "http://localhost/cs/utility/anonymous.gif",
"DisplayName": "danb",
"ProfileUrl": "http://localhost/cs/members/danb/default.aspx",
"Username": "danb",
"CurrentStatus": null,
"Id": 39609
},
"Id": 813
}
],
"Info": [],
"Warnings": [],
"Errors": []
}