longtone Posted May 3, 2008 Share Posted May 3, 2008 I'm still stuck on this one problem: All I want to do is get the Youtube username of a visitor. I can get a single use token using this form: <form action="https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Fwww.djtutor.com%2Ftest4.php&scope=http%3A%2F%2Fgdata.youtube.com&session=1&secure=0" method="post"> <input type="submit" name="submit value="submit"> </form> And I think I should be able to display a feed of their Youtube profile with this: <?php $token = (isset( $_GET['token'])) ? $_GET['token'] : false ; $ch = curl_init(); $url = "http://gdata.youtube.com/feeds/api/users/default"; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: AuthSub token="' . $token . '"\nX-GData-Key: key="OUR_DEVELOPER_KEY"\n\r')); ob_start(); curl_exec ($ch); curl_close ($ch); $string = ob_get_contents(); ob_end_clean(); echo $string; ?> But I get a 401 error, User Authentication required. Is it just a syntax error in the cUrl, or do I need to convert the token to a session token before using it at all? (I'm assuming if it's a single use token I can use it once without converting it) Any ideas? I'm very new to the notion of sending headers with cUrl Link to comment https://forums.phpfreaks.com/topic/103975-solved-sending-headers-to-authsub-on-youtube-api/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.