So it would be nice if one could type in your Drupal.org username, and we fetched your UID. I'm not sure if there's a webservice for this on d.o, I would suspect not.

This would also allow things like auto-completion of the username just like certifiedtorock.com.

Big question is: What's the easiest way to get an array of user IDs from user names?

Comments

tim.plunkett’s picture

I know http://dgo.to has the ability to resolve usernames to UIDs.
http://dgo.to/@Steven%20Jones
http://dgo.to/@tim.plunkett

Not sure how it works, or who even runs that, so that may not be at all helpful information :)

EDIT

On a whim, I tried 'wget http://dgo.to/@Steven%20Jones' and it downloaded the file as '99644'.
That's gotta be useful somehow!

greggles’s picture

We've been thinking of providing this on certifiedtorock as well as a lookup that returns a list of uids and names. If we do end up doing it I'll try to remember to comment here.

Thanks for making this module! Now, to include a badge as a dispaly option :)

Josh The Geek’s picture

curl -I http://dgo.to/@Dries 2> /dev/null | grep Location: | cut -d ' ' -f 2- | cut -d / -f 5 == 1, his d.o uid.

Steven Jones’s picture

Or in Drupal land:


$username = 'Steven Jones';

$uri = 'http://dgo.to/@' . $username;
$options = array(
  // We don't want to follow redirects because we want the location header.
  'max_redirects' => 0,
);
$req = drupal_http_request($uri, $options);
if ($req->code == 302) {
  if (isset($req->headers['location'])) {
    $matches = array();
    if (preg_match('#http:\/\/drupal.org\/user\/(\d+)#', $req->headers['location'], $matches)) {
      return $matches[1];
    }
  }
}
tim.plunkett’s picture

So should we allow users to type in their name, and perform this on validate?

Steven Jones’s picture

Not sure what the best UX would be here, but something along those lines for sure.

Steven Jones’s picture

So we only have an int column stored against the field, so we can't go storing the username entered sadly, but we could still allow input of usernames instead of UIDs and then just transform on validate.

Steven Jones’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Assigned: Unassigned » tim.plunkett
Status: Active » Patch (to be ported)

I've added this to the 7.x branch, http://drupalcode.org/project/ctr_field.git/commit/8b1ba26e190c04836d95a...
Tim, do you want to see if you can add this to the 6.x branch too? It should mostly just directly port, apart from the use of drupal_array_get_nested_value()

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

I haven't had the time for this, sorry.

greggles’s picture

In case it's a little more reliable, there's now http://certifiedtorock.com/person_uid.json/tim.pl