Question

I am using Linq To Twitter and getting an exception when try to fetch followers. Below is my code and the exception.

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

        }

Exception

  InnerException = {"The remote name could not be resolved: 'api.twitter.com'"}

Please suggest

Was it helpful?

Solution

api.twitter.com is the host name of the Twitter API. When LINQ to Twitter makes a query, It uses this as part of the base URL to communicate with Twitter and then adds any endpoint specific paths and parameters. This indicates a network problem where the system the query is run on can't communicate with Twitter. I've seen similar problems in Windows Phone apps running in the Emulator where the emulator isn't connected to the Internet. I've also seen it occur when Fiddler is running and not configured properly. Another possibility is a proxy - if your network has a proxy, you can use the WebProxy property of the TwitterContext instance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top