Here is a simple login function. It returns an error message or 0 on success. I used my own curl lib, but it's pretty clear that $ this-> curl-> SetHeader can be replaced with curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header)
public function login(Model_ServiceAccount $account){ $this->curl->SetHeader('Content-type', 'application/x-www-form-urlencoded'); $this->curl->post('https://www.google.com/youtube/accounts/ClientLogin', 'Email=' . $account->mail->login . '&Passwd=' . $account->mail->password . '&service=youtube&source=whatever'); if (preg_match('~Error=(.+)~', $this->curl->getResponse(), $match)) return $match[1]; if (!preg_match('~Auth=(.*)~', $this->curl->getResponse(), $match)) Toolkit::error('Unhandled error in Authentication request'); $authToken = $match[1]; $this->curl->SetHeader('Authorization: GoogleLogin auth', $this->developerKey); $this->curl->SetHeader('X-GData-Key: key=', $authToken); $this->curl->SetHeader('Content-Type', 'application/atom+xml'); return 0; }
SET
source share