Q:

Youtube PHP API: Verify a youtube username matches up with authentication token

I have a web application where I'm having the user log into youtube to authorize my web application to access their account.  However, I need their youtube user name to actually list their uploaded videos, and I want to ensure that the youtube username they provide matches up with the account they used to authorize with.  In other words, I only want the user to be able to share videos that they've uploaded, and not someone else's. Is there a way to do this?
I had done this before with C# .Net with the following code:
YouTubeRequestSettings yt_settings = new YouTubeRequestSettings(<devID name>, devKey, auth);
YouTubeRequest yt_request = new YouTubeRequest(yt_settings);

Uri uri = new Uri("http://gdata.youtube.com/feeds/api/users/default/uploads/?start-index=1&max-results=1");
Feed<Video> videoFeed = yt_request.Get<Video>(uri);
string uploader = "";
if (videoFeed.Entries.Count() > 0)
    uploader = videoFeed.Entries.ElementAt(0).Uploader;

But when I try something similar with php I get what appears to be a standard feed:
    $yt = new Zend_Gdata_YouTube($http_client,<devID name>,null,$_yt_dev_key);
$feed_url = urlencode("http://gdata.youtube.com/feeds/api/users/default/uploads/?start-index=1&max-results=1");
$videoFeed = $yt->getVideoFeed();
if(count($videoFeed) > 0)
{
    $videoEntry = $videoFeed[0];
    echo var_dump($videoEntry);
}

Anyone have any idea if I'm doing something wrong?
------------------ UPDATE ----------------------
I have the solution to getting youtube video feed for the user in the authenticated session.  $videoFeed = $yt->getuserFeed("default");
Though, I'm still looking at how to get the uploader name from this so that I can perform further video listings directly from javascript (like I had done with my old C#/Asp .Net web app).
----------- A RATHER ROUGH SOLUTION ------------
Well, this isn't exactly an elegant solution, but it's what I have working.
The following will extract the youtube username from a VideoEntry object...
$videoFeed = $yt->getuserUploads("default");
if(count($videoFeed) > 0)
{
    $videoEntry = $videoFeed[0];
    $v_dump = var_export($videoEntry, true);
    $check_for = "http://gdata.youtube.com/feeds/api/users/";
    $pos = strpos($v_dump,$check_for);
    $start_pos = $pos + strlen($check_for);
    $user_name = "";
    for($i = $start_pos; $i < strlen($v_dump); $i++)
    {
        if(($v_dump[$i] == '/') or ($v_dump[$i] == '?'))
            break;
        $user_name .= $v_dump[$i];
    }
    echo $user_name;
}

Basically, I'm parsing through the entire video entry variable string representation for the first generic part of the feed url, then getting the next token in the url which is the username.  In other words, I'm locating this url in the var dump and parsing the username out:
http://gdata.youtube.com/feeds/api/users/<username>/uploads

If anyone can find a better and cleaner way to do it, that'd be awesome.  Parsing a large string like this seems to be a very dirty way of doing this.

A:

See http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Enabling_user_interaction
It says,
Note: Using the string default instead of a username retrieves the profile of the currently authenticated user.

So you can get all the user data about the currently authenticated user using this.
Hope it helps!

