Reputation: 5359
I'm issuing the friends/ids call like so:
GET /1.1/friends/ids.json?screen_name=blablabla HTTP/1.1
A valid response is issued:
{"ids":[97500486,32947624,8884440,2022687,28741369,33978239,10312111,950922,7682036,21688137,7696145,15876098],"next_cursor":0,"next_cursor_str":"0","previous_cursor":0,"previous_cursor_str":"0"}
My interface looks like this:
[OperationContract(Name = "ids.json")]
[WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate="ids.json?user_id={userId}&screen_name={screenName}")]
FriendsIdsResponse Ids(long? userId, string screenName);
[DataContract]
public class FriendsIdsResponse
{
public FriendsIdsResponse()
{
}
[DataMember(Name = "ids")]
public long[] Ids { get; set; }
[DataMember(Name = "previous_cursor")]
public int PreviousCursor { get; set; }
[DataMember(Name = "next_cursor")]
public int NextCursor { get; set; }
}
No matter what type Ids is (long[], IList, List, etc.), it always comes back null. If I instantiate it to an empty List in ctor, it has Count==0.
UPDATE WCF configs, as requested:
<system.serviceModel>
<client>
<endpoint contract="TA.Twitter.Service.IFriends, TA.Twitter.Interfaces"
address="https://api.twitter.com/1.1/friends/"
binding="webHttpBinding" bindingConfiguration="WebHttpBinding"
></endpoint>
</client>
<bindings>
<webHttpBinding>
<binding name="WebHttpBinding" allowCookies="true">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
Upvotes: 3
Views: 210
Reputation: 24558
Not a complete answer, but are you restricted to use WCF to invoke Tweeter API ? I'm a big fan of WCF, but for Twitter there are already many .net Librairies. I understand there is a challenge in WCF but I prefer to not reinvent the wheel each time.
Tweetsharp seems to be a popular .net library for Twitter API access.
Suppose you already have OAuth tokens, get friends is done with less than 10 lines of code.
var service = new TweetSharp.TwitterService("consumerKey", "consumerSecret");
service.AuthenticateWith("accessToken", "accessTokenSecret");
var friends = service.ListFriendIdsOf(new TweetSharp.ListFriendIdsOfOptions() { ScreenName = "blabla" });
foreach (var friend in friends)
{
Console.WriteLine("new friend :{0} ", friend);
}
Less than 10 lines, less than 10 minutes, seems to be a good compromise
Upvotes: 1