我发出这样的朋友/身份证电话:
GET /1.1/friends/ids.json?screen_name=blablabla HTTP/1.1
发出有效响应:
{"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"}
我的界面如下所示:
[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; }
}
无论 Ids 是什么类型(long[]、IList、List 等),它总是返回 null。如果我将它实例化为 ctor 中的一个空列表,它的 Count==0。
根据要求更新WCF 配置:
<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>