![](/img/trans.png)
[英]accessing https://api.twitter.com returns 403 error as forbidden
[英]The remote name could not be resolved: 'api.twitter.com' Linq to Twitter
我正在使用Linq To Twitter,嘗試獲取關注者時出現異常。 下面是我的代碼和例外。
private static async Task<List<TwitterData>> GetTwitterFollowers(
ulong twitterUserId, SingleUserAuthorizer auth, int? maxFollowers)
{
var follower = maxFollowers ?? 15000;
try
{
var twitterCtx = new TwitterContext(auth);
var followers = await twitterCtx.Friendship
.Where(f => f.Type == FriendshipType.FollowersList
&& f.UserID == twitterUserId.ToString())
.Select(f => new TwitterData()
{
Followers = f.Users.Where(t => !t.Protected).Take(follower).Select(s => s).ToList()
}).FirstOrDefaultAsync();
return GetFollowersList(followers.Followers, ref twitterCtx);
}
catch (Exception ex)
{
return null;
}
}
例外
InnerException = {"The remote name could not be resolved: 'api.twitter.com'"}
請建議
api.twitter.com是Twitter API的主機名。 當LINQ to Twitter進行查詢時,它將使用它作為基本URL的一部分與Twitter通信,然后添加任何特定於端點的路徑和參數。 這表明運行查詢的系統無法與Twitter通信的網絡問題。 我在模擬器未運行的Windows Phone應用程序中看到了類似的問題,其中模擬器未連接到Internet。 我還看到了Fiddler運行且配置不正確時發生的情況。 另一種可能性是代理-如果您的網絡具有代理,則可以使用TwitterContext實例的WebProxy屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.