Пример #1
0
function friend($channel)
{
    $username = $_SESSION['username'];
    $query = "select token from user where username='******'";
    $result = mysql_query($query);
    $row = mysql_fetch_array($result);
    $token = $row['token'];
    $httpClient = Zend_Gdata_AuthSub::getHttpClient($token);
    $developerKey = 'AI39si5uCFW5FETweIaPnbNJUP88YvpOtSoy7FSUnYnTFVH4liFKzqWTkndATtgiltByN54tPcVjsScyh3S28P-D4PC4n73alg';
    $applicationId = 'EazySubs';
    $clientId = 'EazySubs';
    $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
    $contactFeedUrl = 'http://gdata.youtube.com/feeds/api/users/default/contacts';
    $newContact = $yt->newContactEntry();
    $newContact->username = $yt->newUsername($channel);
    $newContact->category = array($yt->newCategory('Friends', 'http://gdata.youtube.com/schemas/2007/contact.cat'));
    // post
    try {
        $yt->insertEntry($newContact, $contactFeedUrl);
        return true;
    } catch (Exception $e) {
        return false;
    }
}