本文整理汇总了PHP中Zend_Gdata类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata类的具体用法?PHP Zend_Gdata怎么用?PHP Zend_Gdata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Gdata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWebmastertoolsSitesAction
public function getWebmastertoolsSitesAction()
{
$credentials = $this->getWebmastertoolsCredentials();
if ($credentials) {
$username = $credentials["username"];
$password = $credentials["password"];
}
if ($this->_getParam("username") && $this->_getParam("password")) {
$username = $this->_getParam("username");
$password = $this->_getParam("password");
}
try {
$client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, "sitemaps", Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"));
$service = new Zend_Gdata($client);
$data = $service->getFeed("https://www.google.com/webmasters/tools/feeds/sites/");
foreach ($data->getEntry() as $e) {
$verification = "";
// get verification filename
foreach ($e->getExtensionElements() as $d) {
$a = $d->getExtensionAttributes();
if ($a["type"]["value"] == "htmlpage") {
$verification = $d->getText();
break;
}
}
$sites[] = array("profile" => (string) $e->getTitle(), "verification" => $verification);
}
$this->_helper->json(array("data" => $sites));
} catch (Exception $e) {
$this->_helper->json(false);
}
}
示例2: testNormalOriginalEventShouldHaveNoExtensionElements
public function testNormalOriginalEventShouldHaveNoExtensionElements() {
$this->originalEvent->href = "http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite";
$this->originalEvent->id = "abcdef123456789";
$this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $this->originalEvent->href);
$this->assertEquals("abcdef123456789", $this->originalEvent->id);
$this->assertEquals(0, count($this->originalEvent->extensionElements));
$newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent();
$newOriginalEvent->transferFromXML($this->originalEvent->saveXML());
$this->assertEquals(0, count($newOriginalEvent->extensionElements));
$newOriginalEvent->extensionElements = array(
new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
$this->assertEquals(1, count($newOriginalEvent->extensionElements));
$this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $newOriginalEvent->href);
$this->assertEquals("abcdef123456789", $newOriginalEvent->id);
/* try constructing using magic factory */
$gdata = new Zend_Gdata();
$newOriginalEvent2 = $gdata->newOriginalEvent();
$newOriginalEvent2->transferFromXML($newOriginalEvent->saveXML());
$this->assertEquals(1, count($newOriginalEvent2->extensionElements));
$this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $newOriginalEvent2->href);
$this->assertEquals("abcdef123456789", $newOriginalEvent2->id);
}
示例3: testNormalFeedLinkShouldHaveNoExtensionElements
public function testNormalFeedLinkShouldHaveNoExtensionElements()
{
$this->feedLink->href = "http://www.google.com/calendar/feeds/default/private/full";
$this->feedLink->rel = "via";
$this->feedLink->countHint = "5";
$this->feedLink->readOnly = "false";
$this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $this->feedLink->href);
$this->assertEquals("via", $this->feedLink->rel);
$this->assertEquals("5", $this->feedLink->countHint);
$this->assertEquals("false", $this->feedLink->readOnly);
$this->assertEquals(0, count($this->feedLink->extensionElements));
$newFeedLink = new Zend_Gdata_Extension_FeedLink();
$newFeedLink->transferFromXML($this->feedLink->saveXML());
$this->assertEquals(0, count($newFeedLink->extensionElements));
$newFeedLink->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
$this->assertEquals(1, count($newFeedLink->extensionElements));
$this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $newFeedLink->href);
$this->assertEquals("via", $newFeedLink->rel);
$this->assertEquals("5", $newFeedLink->countHint);
$this->assertEquals("false", $newFeedLink->readOnly);
/* try constructing using magic factory */
$gdata = new Zend_Gdata();
$newFeedLink2 = $gdata->newFeedLink();
$newFeedLink2->transferFromXML($newFeedLink->saveXML());
$this->assertEquals(1, count($newFeedLink2->extensionElements));
$this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $newFeedLink2->href);
$this->assertEquals("via", $newFeedLink2->rel);
$this->assertEquals("5", $newFeedLink2->countHint);
$this->assertEquals("false", $newFeedLink2->readOnly);
}
示例4: testNormalReminderShouldHaveNoExtensionElements
public function testNormalReminderShouldHaveNoExtensionElements()
{
$this->reminder->days = "12";
$this->reminder->minutes = "64";
$this->reminder->absoluteTime = "2007-06-19T12:42:19-06:00";
$this->reminder->method = "email";
$this->reminder->hours = "80";
$this->assertEquals("12", $this->reminder->days);
$this->assertEquals("64", $this->reminder->minutes);
$this->assertEquals("2007-06-19T12:42:19-06:00", $this->reminder->absoluteTime);
$this->assertEquals("email", $this->reminder->method);
$this->assertEquals("80", $this->reminder->hours);
$this->assertEquals(0, count($this->reminder->extensionElements));
$newReminder = new Zend_Gdata_Extension_Reminder();
$newReminder->transferFromXML($this->reminder->saveXML());
$this->assertEquals(0, count($newReminder->extensionElements));
$newReminder->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
$this->assertEquals(1, count($newReminder->extensionElements));
$this->assertEquals("12", $newReminder->days);
$this->assertEquals("64", $newReminder->minutes);
$this->assertEquals("2007-06-19T12:42:19-06:00", $newReminder->absoluteTime);
$this->assertEquals("email", $newReminder->method);
$this->assertEquals("80", $newReminder->hours);
/* try constructing using magic factory */
$gdata = new Zend_Gdata();
$newReminder2 = $gdata->newReminder();
$newReminder2->transferFromXML($newReminder->saveXML());
$this->assertEquals(1, count($newReminder2->extensionElements));
$this->assertEquals("12", $newReminder2->days);
$this->assertEquals("64", $newReminder2->minutes);
$this->assertEquals("2007-06-19T12:42:19-06:00", $newReminder2->absoluteTime);
$this->assertEquals("email", $newReminder2->method);
$this->assertEquals("80", $newReminder2->hours);
}
示例5: testNormalEntryLinkShouldHaveNoExtensionElements
public function testNormalEntryLinkShouldHaveNoExtensionElements()
{
$this->entryLink->href = "http://gmail.com/jo/contacts/Bob";
$this->entryLink->rel = "self";
$this->entryLink->readOnly = "false";
$this->assertEquals("http://gmail.com/jo/contacts/Bob", $this->entryLink->href);
$this->assertEquals("self", $this->entryLink->rel);
$this->assertEquals("false", $this->entryLink->readOnly);
$this->assertEquals(0, count($this->entryLink->extensionElements));
$newEntryLink = new Zend_Gdata_Extension_EntryLink();
$newEntryLink->transferFromXML($this->entryLink->saveXML());
$this->assertEquals(0, count($newEntryLink->extensionElements));
$newEntryLink->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
$this->assertEquals(1, count($newEntryLink->extensionElements));
$this->assertEquals("http://gmail.com/jo/contacts/Bob", $newEntryLink->href);
$this->assertEquals("self", $newEntryLink->rel);
$this->assertEquals("false", $newEntryLink->readOnly);
/* try constructing using magic factory */
$gdata = new Zend_Gdata();
$newEntryLink2 = $gdata->newEntryLink();
$newEntryLink2->transferFromXML($newEntryLink->saveXML());
$this->assertEquals(1, count($newEntryLink2->extensionElements));
$this->assertEquals("http://gmail.com/jo/contacts/Bob", $newEntryLink2->href);
$this->assertEquals("self", $newEntryLink2->rel);
$this->assertEquals("false", $newEntryLink2->readOnly);
}
示例6: FetchContacts
public function FetchContacts($credential = null)
{
if (!$credential) {
$credential = $this->_credential;
} else {
$this->_credential = $credential;
}
$user = $credential['username'];
$pass = $credential['password'];
try {
// perform login and set protocol version to 3.0
$client = \Zend_Gdata_ClientLogin::getHttpClient($user, $pass, 'cp');
$gdata = new \Zend_Gdata($client);
$gdata->setMajorProtocolVersion(3);
// perform query and get result feed
$query = new \Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full');
$query->setParam("max-results", 10000);
$feed = $gdata->getFeed($query);
// parse feed and extract contact information
// into simpler objects
$results = array();
foreach ($feed as $entry) {
$xml = simplexml_load_string($entry->getXML());
$obj = $this->DatatoContact($entry, $xml);
$results[] = $obj;
}
} catch (Exception $e) {
var_dump($e->getMessage());
return;
}
return $results;
}
示例7: userAction
public function userAction()
{
$gologin = Mage::getModel('sociallogin/gologin');
$oauth_data = array('oauth_token' => $this->getRequest()->getParam('oauth_token'), 'oauth_verifier' => $this->getRequest()->getParam('oauth_verifier'));
$requestToken = Mage::getSingleton('core/session')->getRequestToken();
$accessToken = $gologin->getAccessToken($oauth_data, unserialize($requestToken));
$oauthOptions = $gologin->getOptions();
$httpClient = $accessToken->getHttpClient($oauthOptions);
$client = new Zend_Gdata($httpClient);
$feed = $client->getFeed('https://www.google.com/m8/feeds/contacts/default/full');
$userInfo = $feed->getDom();
$user = array();
$tempName = $userInfo->getElementsByTagName("name");
$name = $tempName->item(0)->nodeValue;
//full name
$arrName = explode(' ', $name, 2);
$user['firstname'] = $arrName[0];
$user['lastname'] = $arrName[1];
$tempEmail = $userInfo->getElementsByTagName("email");
$email = $tempEmail->item(0)->nodeValue;
$user['email'] = $email;
$customer = Mage::helper('sociallogin')->getCustomerByEmail($user['email']);
if (!$customer || !$customer->getId()) {
$customer = Mage::helper('sociallogin')->createCustomer($user);
}
Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
die("<script type=\"text/javascript\">try{window.opener.location.reload(true);}catch(e){window.opener.location.href=\"" . Mage::getBaseUrl() . "\"} window.close();</script>");
//$this->_redirectUrl(Mage::helper('customer')->getDashboardUrl());
}
示例8: testNormalWhenShouldHaveNoExtensionElements
public function testNormalWhenShouldHaveNoExtensionElements()
{
$this->when->valueString = "Later";
$this->when->endTime = "2007-06-21T21:31:56-07:00";
$this->when->startTime = "2007-06-19T05:42:19-06:00";
$this->assertEquals("Later", $this->when->valueString);
$this->assertEquals("2007-06-21T21:31:56-07:00", $this->when->endTime);
$this->assertEquals("2007-06-19T05:42:19-06:00", $this->when->startTime);
$this->assertEquals(0, count($this->when->extensionElements));
$newWhen = new Zend_Gdata_Extension_When();
$newWhen->transferFromXML($this->when->saveXML());
$this->assertEquals(0, count($newWhen->extensionElements));
$newWhen->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
$this->assertEquals(1, count($newWhen->extensionElements));
$this->assertEquals("Later", $newWhen->valueString);
$this->assertEquals("2007-06-21T21:31:56-07:00", $newWhen->endTime);
$this->assertEquals("2007-06-19T05:42:19-06:00", $newWhen->startTime);
/* try constructing using magic factory */
$gdata = new Zend_Gdata();
$newWhen2 = $gdata->newWhen();
$newWhen2->transferFromXML($newWhen->saveXML());
$this->assertEquals(1, count($newWhen2->extensionElements));
$this->assertEquals("Later", $newWhen2->valueString);
$this->assertEquals("2007-06-21T21:31:56-07:00", $newWhen2->endTime);
$this->assertEquals("2007-06-19T05:42:19-06:00", $newWhen2->startTime);
}
示例9: testNormalWhereShouldHaveNoExtensionElements
public function testNormalWhereShouldHaveNoExtensionElements()
{
$this->where->valueString = "Test Value String";
$this->where->rel = "http://schemas.google.com/g/2005#event.alternate";
$this->where->label = "Test Label";
$this->assertEquals("Test Value String", $this->where->valueString);
$this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $this->where->rel);
$this->assertEquals("Test Label", $this->where->label);
$this->assertEquals(0, count($this->where->extensionElements));
$newWhere = new Zend_Gdata_Extension_Where();
$newWhere->transferFromXML($this->where->saveXML());
$this->assertEquals(0, count($newWhere->extensionElements));
$newWhere->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
$this->assertEquals(1, count($newWhere->extensionElements));
$this->assertEquals("Test Value String", $newWhere->valueString);
$this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $newWhere->rel);
$this->assertEquals("Test Label", $newWhere->label);
/* try constructing using magic factory */
$gdata = new Zend_Gdata();
$newWhere2 = $gdata->newWhere();
$newWhere2->transferFromXML($newWhere->saveXML());
$this->assertEquals(1, count($newWhere2->extensionElements));
$this->assertEquals("Test Value String", $newWhere2->valueString);
$this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $newWhere2->rel);
$this->assertEquals("Test Label", $newWhere2->label);
}
示例10: testNormalExtendedPropertyShouldHaveNoExtensionElements
public function testNormalExtendedPropertyShouldHaveNoExtensionElements() {
$this->extendedProperty->name = "http://www.example.com/schemas/2007#mycal.foo";
$this->extendedProperty->value = "5678";
$this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $this->extendedProperty->name);
$this->assertEquals("5678", $this->extendedProperty->value);
$this->assertEquals(0, count($this->extendedProperty->extensionElements));
$newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty();
$newExtendedProperty->transferFromXML($this->extendedProperty->saveXML());
$this->assertEquals(0, count($newExtendedProperty->extensionElements));
$newExtendedProperty->extensionElements = array(
new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
$this->assertEquals(1, count($newExtendedProperty->extensionElements));
$this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $newExtendedProperty->name);
$this->assertEquals("5678", $newExtendedProperty->value);
/* try constructing using magic factory */
$gdata = new Zend_Gdata();
$newExtendedProperty2 = $gdata->newExtendedProperty();
$newExtendedProperty2->transferFromXML($newExtendedProperty->saveXML());
$this->assertEquals(1, count($newExtendedProperty2->extensionElements));
$this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $newExtendedProperty2->name);
$this->assertEquals("5678", $newExtendedProperty2->value);
}
示例11: testNormalWhoShouldHaveNoExtensionElements
public function testNormalWhoShouldHaveNoExtensionElements() {
$this->who->valueString = "Test Value String";
$this->who->rel = "http://schemas.google.com/g/2005#event.speaker";
$this->who->email = "testemail@somewhere.domain.invalid";
$this->assertEquals("Test Value String", $this->who->valueString);
$this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $this->who->rel);
$this->assertEquals("testemail@somewhere.domain.invalid", $this->who->email);
$this->assertEquals(0, count($this->who->extensionElements));
$newWho = new Zend_Gdata_Extension_Who();
$newWho->transferFromXML($this->who->saveXML());
$this->assertEquals(0, count($newWho->extensionElements));
$newWho->extensionElements = array(
new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
$this->assertEquals(1, count($newWho->extensionElements));
$this->assertEquals("Test Value String", $newWho->valueString);
$this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $newWho->rel);
$this->assertEquals("testemail@somewhere.domain.invalid", $newWho->email);
/* try constructing using magic factory */
$gdata = new Zend_Gdata();
$newWho2 = $gdata->newWho();
$newWho2->transferFromXML($newWho->saveXML());
$this->assertEquals(1, count($newWho2->extensionElements));
$this->assertEquals("Test Value String", $newWho2->valueString);
$this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $newWho2->rel);
$this->assertEquals("testemail@somewhere.domain.invalid", $newWho2->email);
}
示例12: testExceptionFormatTimestampInvalid
public function testExceptionFormatTimestampInvalid()
{
$gdata = new Zend_Gdata();
try {
$ts = $gdata->formatTimestamp('nonsense string');
} catch (Zend_Gdata_Exception $e) {
$this->assertEquals('Invalid timestamp: nonsense string.', $e->getMessage());
}
}
示例13: userAction
public function userAction()
{
$gologin = Mage::getModel('sociallogin/gologin');
$oauth_data = array('oauth_token' => $this->getRequest()->getParam('oauth_token'), 'oauth_verifier' => $this->getRequest()->getParam('oauth_verifier'));
$requestToken = Mage::getSingleton('core/session')->getRequestToken();
// Fixed by Hai Ta
try {
$accessToken = $gologin->getAccessToken($oauth_data, unserialize($requestToken));
} catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Login failed as you have not granted access.');
die("<script type=\"text/javascript\">try{window.opener.location.reload(true);}catch(e){window.opener.location.href=\"" . Mage::getBaseUrl() . "\"} window.close();</script>");
}
// end fixed
$oauthOptions = $gologin->getOptions();
$httpClient = $accessToken->getHttpClient($oauthOptions);
$client = new Zend_Gdata($httpClient);
$feed = $client->getFeed('https://www.google.com/m8/feeds/contacts/default/full');
$userInfo = $feed->getDom();
$user = array();
$tempName = $userInfo->getElementsByTagName("name");
$name = $tempName->item(0)->nodeValue;
//full name
$arrName = explode(' ', $name, 2);
$user['firstname'] = $arrName[0];
$user['lastname'] = $arrName[1];
$tempEmail = $userInfo->getElementsByTagName("email");
$email = $tempEmail->item(0)->nodeValue;
$user['email'] = $email;
//get website_id and sote_id of each stores
$store_id = Mage::app()->getStore()->getStoreId();
//add
$website_id = Mage::app()->getStore()->getWebsiteId();
//add
$customer = Mage::helper('sociallogin')->getCustomerByEmail($user['email'], $website_id);
//add edition
if (!$customer || !$customer->getId()) {
//Login multisite
$customer = Mage::helper('sociallogin')->createCustomerMultiWebsite($user, $website_id, $store_id);
if (Mage::getStoreConfig('sociallogin/gologin/is_send_password_to_customer')) {
$customer->sendPasswordReminderEmail();
}
}
// fix confirmation
if ($customer->getConfirmation()) {
try {
$customer->setConfirmation(null);
$customer->save();
} catch (Exception $e) {
}
}
Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
die("<script type=\"text/javascript\">try{window.opener.location.href=\"" . $this->_loginPostRedirect() . "\";}catch(e){window.opener.location.reload(true);} window.close();</script>");
//$this->_redirectUrl(Mage::helper('customer')->getDashboardUrl());
}
示例14: import
public static function import($uri, $client = null, $className = 'Zend_Gdata_Feed')
{
$app = new Zend_Gdata($client);
$requestData = $app->decodeRequest('GET', $uri);
$response = $app->performHttpRequest($requestData['method'], $requestData['url']);
$feedContent = $response->getBody();
$feed = self::importString($feedContent, $className);
if ($client != null) {
$feed->setHttpClient($client);
}
return $feed;
}
示例15: testGetEntryExceptionInvalidLocationType
public function testGetEntryExceptionInvalidLocationType()
{
$gdata = new Zend_Gdata();
try {
// give it neither a string nor a Zend_Gdata_Query object,
// and see if it throws an exception.
$feed = $gdata->getEntry(new stdClass());
$this->fail('Expecting to catch Zend_Gdata_App_InvalidArgumentException');
} catch (Zend_Exception $e) {
$this->assertType('Zend_Gdata_App_InvalidArgumentException', $e, 'Expecting Zend_Gdata_App_InvalidArgumentException, got ' . get_class($e));
$this->assertEquals('You must specify the location as either a string URI or a child of Zend_Gdata_Query', $e->getMessage());
}
}