Jump to content

[SOLVED] GData Authentication with PHP headers, am I doing this right.


longtone

Recommended Posts

OK, I'm very new to using  headers, so I might be going about this completely wrong:

 

I want to view a user's Youtube profile using the GData API

After successfully requesting a token I run this PHP script:

 

<?php

 

if (isset( $_GET['token'])) {

$token = $_GET['token'];

}

 

//Authorise

 

  header('Authorization: AuthSub token="' . $token . '"' );

  header('X-GData-Key: key="my_developer_key" ');

 

 

echo '<p><a href="http://gdata.youtube.com/feeds/api/users/default" >Get Profile</a>';

 

?>

 

But I get a 401 error

User authentication required.

 

Am I using these headers properly?

changed it to file_get_contents instead of a link:

 

 

<?php
//Get Token
if (isset( $_GET['token'])) {
$token = $_GET['token'];
}

//Authorise
header('Authorization: AuthSub token="' . $token . '"' );
header('X-GData-Key: key="my_developer_key" ');

//Request profile
echo file_get_contents("http://gdata.youtube.com/feeds/api/users/default") ;
?>

 

Still get the same error though

 

This is what they're asking for:

 

When you make an authenticated API request using an AuthSub authentication token, your request needs to specify the Authorization HTTP request header as shown in the example below. Note: In this document, sample requests use AuthSub syntax unless otherwise specified.

 

Authorization: AuthSub token=<authentication_token>

X-GData-Key: key=<developer_key>

 

Am I doing the right thing with headers at all?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.