hi, im trying to subscribe a user to a channel(GoogleDevelopers) via
the youtube API and i keep getting this error. does anyone know whats
wrong? here is a copy of the code: (note: i switched the channel to
GoogleDevelopers channel just to make sure the problem isn't my
channel username)
function subscribeUser($token){
//$token is the temp authsub token
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_YouTube_Extension_Username');
Zend_Loader::loadClass('Zend_Gdata_YouTube_SubscriptionEntry');
$applicationId ='myApplicationId';
$clientId = '';
$subscriptionsFeedUrl = "http://gdata.youtube.com/feeds/api/users/
default/subscriptions";
$channel = 'GoogleDevelopers';
//get session token
$SESSION['sessionToken'] =
Zend_Gdata_AuthSub::getAuthSubSessionToken($token);
$httpClient =
Zend_Gdata_AuthSub::getHttpClient($SESSION['sessionToken']);
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId,
$_SESSION['developerKey']);
$yt->enableRequestDebugLogging('/tmp/log.txt');
$newSubscription =$yt->newSubscriptionEntry();
$newSubscription->setUsername(new
Zend_Gdata_YouTube_Extension_Username($channel));
// post
$entry = $yt->insertEntry($newSubscription, $subscriptionsFeedUrl);
}
and here is the error i get printed in the log.txt file:
Connecting to: gdata.youtube.com:80
POST /feeds/api/users/default/subscriptions HTTP/1.1
Host: gdata.youtube.com
Connection: close
X-GData-Key: key=myDeveloperKey
User-Agent: MyCompany-MyApp-1.0 Zend_Framework_Gdata/1.11.10
authorization: AuthSub token="1/7QP4IckRuwDR0t09_authSubToken"
Content-Type: application/atom+xml
Accept-encoding: identity
Content-Length: 158
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"><yt:username
xmlns:yt="http://gdata.youtube.com/schemas/2007">GoogleDevelopers</
yt:username></atom:entry>Closing socket
HTTP/1.1 400 Bad Request
X-GData-User-Country: US
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Date: Fri, 19 Aug 2011 00:25:36 GMT
Expires: Fri, 19 Aug 2011 00:25:36 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Connection: close
1C
Missing or invalid username.