views:

626

answers:

2

First off, I'm doing a contest where users must tweet a message 'just entered #cool-contest, more info at http://unique/url/239843' and I'm basically doing a search using the api:

http://search.twitter.com/search.atom?q=%40twitterapi+OR+%40twitter

Sample entry element:

  <entry>
    <id>tag:search.twitter.com,2005:5266369259</id>
    <published>2009-10-29T19:03:56Z</published>
    <link type="text/html" href="http://twitter.com/mytweetsnl/statuses/5266369259" rel="alternate"/>
    <title>THE_REAL_SHAQ: Shaq-A-Claus is coming to town! Check out my &#8220;Join Shaq Give Back&#8221; challenge, coming.. http://bit.ly/1OVKHR&lt;/title&gt;
    <content type="html">THE_REAL_SHAQ: &lt;b&gt;Shaq-A-Claus&lt;/b&gt; is coming to town! Check out my &#8220;Join Shaq Give Back&#8221; challenge, coming.. &lt;a href=&quot;http://bit.ly/1OVKHR&amp;quot;&amp;gt;http://bit.ly/1OVKHR&amp;lt;/a&amp;gt;&lt;/content&gt;
    <updated>2009-10-29T19:03:56Z</updated>
    <link type="image/png" href="http://a3.twimg.com/profile_images/298078521/twitter_normal.gif" rel="image"/>
    <twitter:geo>
    </twitter:geo>
    <twitter:source>&lt;a href=&quot;http://twitterfeed.com&amp;quot; rel=&quot;nofollow&quot;&gt;twitterfeed&lt;/a&gt;</twitter:source>
    <twitter:lang>en</twitter:lang>
    <author>
      <name>mytweetsnl (MyTweets.nl)</name>
      <uri>http://twitter.com/mytweetsnl&lt;/uri&gt;
    </author>
  </entry>

I'm basically trying to search all retweets of the initial user ( me ) and tracking the string '#cool-contest' and 'http://unique/url/239843' from the content element, then inserting the entries into a local database, but before I actually insert the entry I also need to determine whether said user is a follower or not, and this is why I need the user id to cross reference with followers:

http://twitter.com/followers/ids.xml?screen%5Fname=101010

Is there an extra parameter I'm missing so I can actually see the user ID? If not would the only way be to parse the twitter URI, so grab the username after 'twitter.com/user' from the author element and feed it as a name parameter?

http://twitter.com/followers/ids.xml?screen%5Fname=mytweetsnl

I'm just a little hesistant because I'm not sure if the screen name is reliable since it may be updated in the future.

My initial questions about this project ( if you want more info ): http://stackoverflow.com/questions/1648161/tweet-contest-logic-twitter

+1  A: 

If you use the search API and parse the json you can get the from_user_id property and therefore their user id

http://search.twitter.com/search.json?q=google

monkeylee
Ahh, I should have checked the json version of that, thank you.
meder
+2  A: 

Use the json format of the Twitter search API.

Curently, the user_ids from the search API are not the same as the Twitter user IDs used everywhere else. This is a common problem.

The user ids in the Search API are different from those in the REST API (about the two APIs). This defect is being tracked by Issue 214. This means that the to_user_id and from_user_id field vary from the actualy user id on Twitter.com. Applications will have to perform a screen name-based lookup with the users/show method to get the correct user id if necessary.

Ryan McGeary
Since I have to rely on the screen name anyway, do you think I should just not bother with the user id and instead rely solely on the screen name?
meder
Actually I might still have to rely on the user id because the page with followers only returns user ids... ack.
meder
Yeah, whether you need to look up the true user ID is dependent on what you want to do. This is truly a big flaw in the search API and one that's been outstanding for too long.
Ryan McGeary