1. Go to this page and download the library: Download gwa/google-data-contact library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gwa / google-data-contact example snippets
use Gwa\GoogleContact\Contact;
// Create a new contact.
$contact = new Contact();
// Set the name.
// Arguments: last, first, middle
$contact->setName('Doe', 'John')
// Prefix and suffix can also be set
->setNamePrefix('Dr.')
->setNameSuffix('MD');
// Add a note.
$contact->setNote('Lorem ipsum');
// Add one or more email addresses.
// Arguments: address, type (opt.), is primary? (opt.)
$contact->addEmail('[email protected]', 'home', true);
// Type defaults to "work"
$contact->addEmail('[email protected]');
// Add one or more phone numbers.
// Arguments: number, type (opt.), is primary? (opt.)
$contact->addPhoneNumber('012 3456 789', 'home', true);
// Add one or more addresses.
$contact->addAddress('1600 Amphitheatre Parkway', 'work', true)
->setCity('Mountain View')
->setRegion('California')
->setPostCode('94043')
// Arguments: County, Country code (opt.) https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
->setCountry('U.S.A.', 'US');
// Add one or more organizations.
// Arguments: name, type (opt.), is primary? (opt.)
$contact->addOrganization('Google, Inc.')
->setType('other')
->setLabel('Volunteer')
->setPrimary()
->setTitle('Tech Writer')
->setJobDescription('Writes documentation')
->setDepartment('Software Development')
->setSymbol('GOOG');
// Access existing elements using 0-based index:
$email1 = $contact->email(0);
$email2 = $contact->email(1);
$phonenumber1 = $contact->phoneNumber(0);
$address1 = $contact->address(0);
$organization1 = $contact->organization(0);
// Render as XML.
$xmlstring = $contact->render();
use Gwa\GoogleContact\ContactFactory;
$factory = new ContactFactory();
// XML above is in $xml. Returns an array of Contact objects.
$contacts = $factory->createFromFeedXmlString($xml);
$factory = new ContactFactory();
// XML above is in $xml. Returns a single Contact object.
$contact = $factory->createFromXmlString($xml);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.