[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/Zend/Gdata/ -> Contacts.php (source)

   1  <?php
   2  
   3  /**
   4   * https://github.com/prasad83/Zend-Gdata-Contacts
   5   * @author prasad
   6   * 
   7   * LICENSE
   8   *
   9   * This source file is subject to the new BSD license that is bundled
  10   * with this package in the file LICENSE.txt.
  11   * It is also available through the world-wide-web at this URL:
  12   * http://framework.zend.com/license/new-bsd
  13   * If you did not receive a copy of the license and are unable to
  14   * obtain it through the world-wide-web, please send an email
  15   * to [email protected] so we can send you a copy immediately.
  16   *
  17   * @category   Zend
  18   * @package    Zend_Gdata
  19   * @subpackage Contacts
  20   */
  21  require_once  'Zend/Gdata.php';
  22  require_once  'Zend/Gdata/Contacts/ListFeed.php';
  23  require_once  'Zend/Gdata/Contacts/ListEntry.php';
  24  require_once  'Zend/Gdata/Contacts/Query.php';
  25  
  26  class Zend_Gdata_Contacts extends Zend_Gdata {
  27  
  28      const CONTACTS_MAJOR_PROTOCOL_VERSION = 3;
  29      const CONTACTS_MINOR_PROTOCOL_VERSION = 0;
  30      
  31      const CONTACTS_FEED_URI = 'https://www.google.com/m8/feeds/contacts';
  32      const CONTACTS_POST_URI = 'https://www.google.com/m8/feeds/contacts/default/full';
  33      const AUTH_SERVICE_NAME = 'cp';
  34      
  35      protected $_projection = 'full';
  36      protected $_visibility = 'private';
  37      
  38         protected $_registeredPackages = array('Zend_Gdata_Contacts');
  39  
  40      protected $_defaultPostUri = self::CONTACTS_POST_URI;
  41  
  42      public static $namespaces = array(
  43          array('gd', 'http://schemas.google.com/g/2005', self::CONTACTS_MAJOR_PROTOCOL_VERSION, self::CONTACTS_MINOR_PROTOCOL_VERSION)
  44      );
  45  
  46  	public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0') {
  47          $this->registerPackage('Zend_Gdata_Contacts');
  48          $this->registerPackage('Zend_Gdata_Contacts_Extension'); // used for new* creation
  49          parent::__construct($client, $applicationId);
  50          
  51          $this->setMajorProtocolVersion(self::CONTACTS_MAJOR_PROTOCOL_VERSION);
  52          $this->setMinorProtocolVersion(self::CONTACTS_MINOR_PROTOCOL_VERSION);
  53          
  54          $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
  55      }
  56  
  57  
  58  	public function setProjection($value) {
  59          $this->_projection = $value;
  60          return $this;
  61      }
  62      
  63  	public function getProjection() {
  64          return $this->_projection;
  65      }
  66      
  67  	public function insertContact($contact, $uri=null) {
  68              if ($uri == null) {
  69                  $uri = $this->_defaultPostUri;
  70                  }
  71              $newContact = $this->insertEntry($contact, $uri, 'Zend_Gdata_Contacts_ContactEntry');
  72              return $newContact;
  73          }
  74      
  75  	public function getContactListFeed($location = null) {
  76              if ($location == null) {
  77                      $uri = self::CONTACTS_FEED_URI . '/default/full';
  78              } else if ($location instanceof Zend_Gdata_Query) {
  79                  $uri = $location->getQueryUrl();
  80                 } else {
  81                      $uri = $location;
  82              }
  83          
  84          return parent::getFeed($uri, 'Zend_Gdata_Contacts_ListFeed');
  85      }
  86      
  87  	public function getContactListEntry($location = NULL) {
  88          if ($location == null) {
  89              require_once  'Zend/Gdata/App/InvalidArgumentException.php';
  90              throw new Zend_Gdata_App_InvalidArgumentException(
  91                      'Location must not be null');
  92          } else if ($location instanceof Zend_Gdata_Query) {
  93              $uri = $location->getQueryUrl();
  94          } else {
  95              $uri = $location;
  96          }
  97          return parent::getEntry($uri,'Zend_Gdata_Contacts_ContactEntry');
  98      }
  99       
 100  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1