Ulong vs string

Jun 30, 2009 at 11:24 PM
Edited Jun 30, 2009 at 11:45 PM

Looking at the example below. The property ID is as ULONG in SocialGraph and string in User. This ok ?
tks

var friends = from friend in twitterCtx.SocialGraph
where friend.Type == SocialGraphType.Friends &&
friend.UserID==111111 select friend;

var users = from tweet in twitterCtx.User
where tweet.Type == UserType.Followers &&
tweet.ID == twitterCtx.UserName
select tweet;

Coordinator
Jul 1, 2009 at 3:35 AM

Good observation. The Twitter API docs say that ID can be either an id or screen name, but UserID is an id. Therefore, ID is a string, but UserID is a ulong.  I reviewed the API and changed ID fields to string where appropriate.  UserID will remain a ulong because it helps protect you from accidentally passing a screen name.  BTW, many of the APIs have a ScreenName property that takes a string, which might make for more readable code if you are actually passing the screen name.  I checked in the latest updates here:

http://linqtotwitter.codeplex.com/SourceControl/changeset/view/55782

Joe

Jul 1, 2009 at 10:34 AM

Hi Joe,
I'm try using friend.ID == twitterCtx.UserName this ok? Using friend.ScreenName he does not return data.
tks


 var friends =
                from friend in twitterCtx.SocialGraph
                where friend.Type == SocialGraphType.Friends &&
                friend.ID == twitterCtx.UserName
                select friend;

            friends.ToList().ForEach(
                friend => Console.WriteLine("Friend ID: " + friend.ID));

Coordinator
Jul 1, 2009 at 1:10 PM

Using friend.ID == twitterCtx.UserName will work.  However, it is redundant because if you leave it out, Twitter will return a list of friends for the currently logged-in user, which is the same as twitterCtx.UserName.

I just tested ScreenName and it's working for me.  Here's my query:

            var friends =
                from friend in twitterCtx.SocialGraph
                where friend.Type == SocialGraphType.Friends &&
                          friend.ScreenName == "JoeMayo"
                select friend;

Joe

Jul 1, 2009 at 5:01 PM

Hi Joe,
Please try the code below to see if it returns the UserID. On my return blank

friends.ToList().ForEach(
friend => Console.WriteLine("Friend ID: " + friend.UserID));

tks

Coordinator
Jul 1, 2009 at 5:46 PM

The only value returned by SocialGraph is the ID. Everything else is blank because Twitter only returns IDs:

http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-friends%C2%A0ids

Joe