├── .gitignore ├── CONTRIBUTORS ├── LICENSE ├── README.md ├── Services ├── FullContact.php └── FullContact │ ├── API.php │ ├── Company.php │ ├── Exception │ ├── Base.php │ ├── NoCredit.php │ └── NotImplemented.php │ ├── Icon.php │ ├── Location.php │ ├── Name.php │ └── Person.php ├── composer.json ├── creds-dist.php ├── example ├── index.php ├── person-email.php └── person-md5.php └── tests ├── FullContactAPITest.php ├── NameTest.php ├── PersonTest.php └── phpunit.xml /.gitignore: -------------------------------------------------------------------------------- 1 | /creds.php 2 | /nbproject/* 3 | /vendor/* 4 | /composer.lock 5 | /tmp* 6 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who have contributed to the fullcontact-api-php library. 2 | 3 | FullContact 4 | D. Keith Casey, Jr. 5 | Mario Falomir 6 | Dominic Dimarco 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 FullContact, Inc 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FullContact PHP Library 2 | ================ 3 | 4 | This is a PHP helper for the FullContact API - http://www.fullcontact.com/ 5 | 6 | It is modeled after the Twilio PHP Helper library because I think it's generally well done and thought through. This isn't official but should generally work except for the incomplete items in the TODO list below. 7 | 8 | This is v0.9.0 so it is pretty stable and I don't expect the interfaces to change much if at all. 9 | 10 | ## Requirements 11 | 12 | This assumes you have cURL installed along with the corresponding php-curl interface. It could be extended to support other HTTP transport tools but I'm kinda lazy. 13 | 14 | ## Getting started 15 | 16 | You have to have a FullContact account. Then copy the creds-dist.php file to creds.php and fill in the API Key. Then you should be able to run any of the scripts in /examples out of the box. 17 | 18 | The code itself is pretty simple. You initialize the selected object with the API Key and go from there: 19 | 20 | ```php 21 | $this->name = new Services_FullContact_Name($apikey); 22 | ``` 23 | 24 | ## Testing 25 | 26 | This is set up to use a basic PHPUnit configuration. I happened to use 3.7.8 but it shouldn't make a difference. From the root of the project, you should be able to execute the tests using: 27 | 28 | ```shell 29 | phpunit tests/ 30 | ``` 31 | 32 | ## TODO 33 | 34 | **This library is not complete but here is the active todo list.** 35 | 36 | * For the Person resource 37 | * ~~Implement lookup by email and emailMD5~~ 38 | * Implement style for outputting (lookup by email only) 39 | * ~~Implement lookup by phone~~ 40 | * Implement countryCode for non-US/Canada phone numbers 41 | * ~~Implement lookup by twitter~~ 42 | * Implement lookup by vCard 43 | * Implement queue and callback for queue-based processing 44 | * --Implement webhookUrl and webhookId for asynchronous processing-- 45 | * Implement css and prettyPrint for output 46 | * Implement Enhanced Lookup retrieval 47 | * For the Name resource 48 | * ~~Implement normalization with casing~~ 49 | * ~~Implement deducer using email or username with casing~~ 50 | * ~~Implement similarity with casing~~ 51 | * Implement stats with casing using ~~name, givenName, familyName,~~ and both (givenName and familyName) 52 | * ~~Implement parser with casing~~ 53 | * ~~For the Location resource~~ 54 | * ~~Implement normalization using includeZeroPopulation and casing~~ 55 | * ~~Implement enrichment using includeZeroPopulation and casing~~ 56 | * For the Icon resource 57 | * ~~Implement the way to get all available icons~~ 58 | * Implement icon retrieval using size and type 59 | * Implement the CardShark resource 60 | * Implement disposable email address detection 61 | * Implement account stats retrieval 62 | * ~~Update the library to be backwards compatible with the previous official version~~ 63 | * Update the test to use Mocks instead of live API hits.. because it could drain your account credits. Doh. 64 | 65 | 66 | ## License 67 | 68 | All code included is Apache License. 69 | 70 | Copyright (C) 2013, FullContact and contributors 71 | 72 | 73 | Licensed under the Apache License, Version 2.0 (the "License"); 74 | you may not use this file except in compliance with the License. 75 | You may obtain a copy of the License at 76 | 77 | http://www.apache.org/licenses/LICENSE-2.0 78 | 79 | Unless required by applicable law or agreed to in writing, software 80 | distributed under the License is distributed on an "AS IS" BASIS, 81 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 82 | See the License for the specific language governing permissions and 83 | limitations under the License. -------------------------------------------------------------------------------- /Services/FullContact.php: -------------------------------------------------------------------------------- 1 | 35 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 36 | */ 37 | class Services_FullContact 38 | { 39 | const USER_AGENT = 'caseysoftware/fullcontact-php-0.9.0'; 40 | 41 | protected $_baseUri = 'https://api.fullcontact.com/'; 42 | protected $_version = 'v2'; 43 | 44 | protected $_apiKey = null; 45 | protected $_webhookUrl = null; 46 | protected $_webhookId = null; 47 | 48 | public $response_obj = null; 49 | public $response_code = null; 50 | public $response_json = null; 51 | 52 | /** 53 | * The base constructor needs the API key available from here: 54 | * http://fullcontact.com/getkey 55 | * 56 | * @param type $api_key 57 | */ 58 | public function __construct($api_key) 59 | { 60 | $this->_apiKey = $api_key; 61 | } 62 | 63 | /** 64 | * This sets the webhook url for all requests made for this service 65 | * instance. To unset, just use setWebhookUrl(null). 66 | * 67 | * @author David Boskovic @dboskovic 68 | * @param string $url 69 | * @param string $id 70 | * @return object 71 | */ 72 | public function setWebhookUrl($url, $id = null) { 73 | $this->_webhookUrl = $url; 74 | $this->_webhookId = $id; 75 | return $this; 76 | } 77 | 78 | /** 79 | * This is a pretty close copy of my work on the Contactually PHP library 80 | * available here: http://github.com/caseysoftware/contactually-php 81 | * 82 | * @author Keith Casey 83 | * @author David Boskovic @dboskovic 84 | * @param array $params 85 | * @return object 86 | * @throws Services_FullContact_Exception_NotImplemented 87 | */ 88 | protected function _execute($params = array()) 89 | { 90 | if (!in_array($params['method'], $this->_supportedMethods)) { 91 | throw new Services_FullContact_Exception_NotImplemented(__CLASS__ . 92 | " does not support the [" . $params['method'] . "] method"); 93 | } 94 | 95 | if ($this->_webhookUrl) { 96 | $params['webhookUrl'] = $this->_webhookUrl; 97 | } 98 | 99 | if ($this->_webhookId) { 100 | $params['webhookId'] = $this->_webhookId; 101 | } 102 | 103 | $fullUrl = $this->_baseUri . $this->_version . $this->_resourceUri . 104 | '?' . http_build_query($params); 105 | 106 | $headers = [ 107 | 'Authorization: Bearer ' . $this->_apiKey, 108 | ]; 109 | 110 | //open connection 111 | $connection = curl_init($fullUrl); 112 | curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); 113 | curl_setopt($connection, CURLOPT_USERAGENT, self::USER_AGENT); 114 | curl_setopt($connection, CURLOPT_HTTPHEADER, $headers); 115 | 116 | //execute request 117 | $this->response_json = curl_exec($connection); 118 | $this->response_code = curl_getinfo($connection, CURLINFO_HTTP_CODE); 119 | $this->response_obj = json_decode($this->response_json); 120 | 121 | if ('403' == $this->response_code) { 122 | throw new Services_FullContact_Exception_NoCredit($this->response_obj->message); 123 | } 124 | 125 | return $this->response_obj; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Services/FullContact/API.php: -------------------------------------------------------------------------------- 1 | lookupByEmail($search); 35 | break; 36 | case 'phone': 37 | $this->lookupByPhone($search); 38 | break; 39 | case 'twitter': 40 | $this->lookupByTwitter($search); 41 | break; 42 | default: 43 | throw new FullContactAPIException("UnsupportedLookupMethodException: Invalid lookup method specified [{$type}]"); 44 | break; 45 | } 46 | 47 | $result = json_decode($this->response_json, true); 48 | $result['is_error'] = !in_array($this->response_code, array(200, 201, 204)); 49 | 50 | return $result; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Services/FullContact/Company.php: -------------------------------------------------------------------------------- 1 | 22 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 23 | */ 24 | class Services_FullContact_Company extends Services_FullContact 25 | { 26 | /** 27 | * Supported lookup methods 28 | * @var $_supportedMethods 29 | */ 30 | protected $_supportedMethods = array('domain'); 31 | protected $_resourceUri = '/company/lookup.json'; 32 | 33 | public function lookupByDomain($search) 34 | { 35 | $this->_execute(array('domain' => $search, 'method' => 'domain')); 36 | 37 | return $this->response_obj; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Services/FullContact/Exception/Base.php: -------------------------------------------------------------------------------- 1 | 22 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 23 | */ 24 | class Services_FullContact_Icon extends Services_FullContact 25 | { 26 | protected $_supportedMethods = array('available'); 27 | protected $_resourceUri = '/icon/'; 28 | 29 | public function available() 30 | { 31 | $this->_execute(array('method' => 'available')); 32 | 33 | return $this->response_obj; 34 | } 35 | } -------------------------------------------------------------------------------- /Services/FullContact/Location.php: -------------------------------------------------------------------------------- 1 | 22 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 23 | */ 24 | class Services_FullContact_Location extends Services_FullContact 25 | { 26 | /** 27 | * Supported lookup methods 28 | * @var $_supportedMethods 29 | */ 30 | protected $_supportedMethods = array('normalizer', 'enrichment'); 31 | protected $_resourceUri = ''; 32 | 33 | /** 34 | * This takes a name and breaks it into its individual parts. 35 | * 36 | * @param type $name 37 | * @param type $casing -> valid values are uppercase, lowercase, titlecase 38 | * @return type 39 | */ 40 | public function normalizer($place, $includeZeroPopulation = false, $casing = 'titlecase') 41 | { 42 | $includeZeroPopulation = ($includeZeroPopulation) ? 'true' : 'false'; 43 | 44 | $this->_resourceUri = '/address/locationNormalizer.json'; 45 | $this->_execute(array('place' => $place, 'includeZeroPopulation' => $includeZeroPopulation, 46 | 'method' => 'normalizer', 'casing' => $casing)); 47 | 48 | return $this->response_obj; 49 | } 50 | 51 | public function enrichment($place, $includeZeroPopulation = false, $casing = 'titlecase') 52 | { 53 | $includeZeroPopulation = ($includeZeroPopulation) ? 'true' : 'false'; 54 | 55 | $this->_resourceUri = '/address/locationEnrichment.json'; 56 | $this->_execute(array('place' => $place, 'includeZeroPopulation' => $includeZeroPopulation, 57 | 'method' => 'enrichment', 'casing' => $casing)); 58 | 59 | return $this->response_obj; 60 | } 61 | } -------------------------------------------------------------------------------- /Services/FullContact/Name.php: -------------------------------------------------------------------------------- 1 | 22 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 23 | */ 24 | class Services_FullContact_Name extends Services_FullContact 25 | { 26 | /** 27 | * Supported lookup methods 28 | * @var $_supportedMethods 29 | */ 30 | protected $_supportedMethods = array('normalizer', 'deducer', 'similarity', 'stats', 'parser'); 31 | protected $_resourceUri = ''; 32 | 33 | /** 34 | * This takes a name and breaks it into its individual parts. 35 | * 36 | * @param type $name 37 | * @param type $casing -> valid values are uppercase, lowercase, titlecase 38 | * @return type 39 | */ 40 | public function normalizer($name, $casing = 'titlecase') 41 | { 42 | $this->_resourceUri = '/name/normalizer.json'; 43 | $this->_execute(array('q' => $name, 'method' => 'normalizer', 'casing' => $casing)); 44 | 45 | return $this->response_obj; 46 | } 47 | 48 | /** 49 | * This resolves a person's name from either their email address or a 50 | * username. This is basically a wrapper for the Person lookup methods. 51 | * 52 | * @param type $name 53 | * @param type $type -> valid values are email and username 54 | * @param type $casing -> valid values are uppercase, lowercase, titlecase 55 | * @return type 56 | */ 57 | public function deducer($value, $type = 'email', $casing = 'titlecase') 58 | { 59 | $this->_resourceUri = '/name/deducer.json'; 60 | $this->_execute(array($type => $value, 'method' => 'deducer', 'casing' => $casing)); 61 | 62 | return $this->response_obj; 63 | } 64 | 65 | /** 66 | * These are two names to compare. 67 | * 68 | * @param type $name1 69 | * @param type $name2 70 | * @param type $casing 71 | * @return type 72 | */ 73 | public function similarity($name1, $name2, $casing = 'titlecase') 74 | { 75 | $this->_resourceUri = '/name/similarity.json'; 76 | $this->_execute(array('q1' => $name1, 'q2' => $name2, 'method' => 'similarity', 'casing' => $casing)); 77 | 78 | return $this->response_obj; 79 | } 80 | 81 | public function stats($value, $type = 'givenName', $casing = 'titlecase') 82 | { 83 | $this->_resourceUri = '/name/stats.json'; 84 | $this->_execute(array($type => $value, 'method' => 'stats', 'casing' => $casing)); 85 | 86 | return $this->response_obj; 87 | } 88 | public function parser($name, $casing = 'titlecase') 89 | { 90 | $this->_resourceUri = '/name/parser.json'; 91 | $this->_execute(array('q' => $name, 'method' => 'parser', 'casing' => $casing)); 92 | 93 | return $this->response_obj; 94 | } 95 | } -------------------------------------------------------------------------------- /Services/FullContact/Person.php: -------------------------------------------------------------------------------- 1 | 22 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 23 | */ 24 | class Services_FullContact_Person extends Services_FullContact 25 | { 26 | /** 27 | * Supported lookup methods 28 | * @var $_supportedMethods 29 | */ 30 | protected $_supportedMethods = array('email', 'phone', 'twitter'); 31 | protected $_resourceUri = '/person.json'; 32 | 33 | public function lookupByEmail($search) 34 | { 35 | $this->_execute(array('email' => $search, 'method' => 'email')); 36 | 37 | return $this->response_obj; 38 | } 39 | 40 | public function lookupByEmailMD5($search) 41 | { 42 | $this->_execute(array('emailMD5' => $search, 'method' => 'email')); 43 | 44 | return $this->response_obj; 45 | } 46 | 47 | public function lookupByPhone($search) 48 | { 49 | $this->_execute(array('phone' => $search, 'method' => 'phone')); 50 | 51 | return $this->response_obj; 52 | } 53 | 54 | public function lookupByTwitter($search) 55 | { 56 | $this->_execute(array('twitter' => $search, 'method' => 'twitter')); 57 | 58 | return $this->response_obj; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fullcontact/sdk", 3 | "type": "library", 4 | "description": "A PHP wrapper for Full Contacts's API", 5 | "keywords": ["fullcontact", "address", "api"], 6 | "homepage": "http://github.com/fullcontact/fullcontact-api-php", 7 | "license": "Apache", 8 | "authors": [ 9 | { 10 | "name": "FullContact" 11 | }, 12 | { 13 | "name": "Keith Casey", 14 | "email": "contrib@caseysoftware.com" 15 | } 16 | ], 17 | "require": { 18 | "php": ">=5.2.1" 19 | }, 20 | "require-dev": { 21 | "mockery/mockery": ">=0.7.2" 22 | }, 23 | "autoload": { 24 | "psr-0": { 25 | "Services_FullContact": "" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /creds-dist.php: -------------------------------------------------------------------------------- 1 | doLookup('bart@fullcontact.com'); 12 | 13 | //dump our results 14 | echo "
----------------
";
15 | print_r($result);
16 | echo "

----------------
\n"; 17 | -------------------------------------------------------------------------------- /example/person-email.php: -------------------------------------------------------------------------------- 1 | setWebhookUrl('URL','ID (optional)'); // optional webhook callback 10 | $result = $fullcontact->lookupByEmail('bart@fullcontact.com'); 11 | 12 | //dump our results 13 | echo "
----------------
";
14 | print_r($result);
15 | echo "

----------------
\n"; -------------------------------------------------------------------------------- /example/person-md5.php: -------------------------------------------------------------------------------- 1 | lookupByEmailMD5($emailMD5); 12 | 13 | //dump our results 14 | echo "
----------------
";
15 | print_r($result);
16 | echo "

----------------
\n"; -------------------------------------------------------------------------------- /tests/FullContactAPITest.php: -------------------------------------------------------------------------------- 1 | 26 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 27 | */ 28 | 29 | class FullContactAPITest extends PHPUnit_Framework_TestCase 30 | { 31 | public function setUp() 32 | { 33 | global $apikey; 34 | 35 | $this->client_old = new FullContactAPI($apikey); 36 | $this->client_new = new Services_FullContact_API($apikey); 37 | 38 | parent::setUp(); 39 | } 40 | 41 | public function testDoLookupEmail() 42 | { 43 | $result = $this->client_old->doLookup('bart@fullcontact.com'); 44 | $this->assertArrayHasKey('status', $result); 45 | $this->assertEquals(200, $result['status']); 46 | $this->assertEquals('Lorang', $result['contactInfo']['familyName']); 47 | $this->assertGreaterThanOrEqual(11, count($result['socialProfiles'])); 48 | } 49 | 50 | public function testBadEmail() 51 | { 52 | $result = $this->client_old->doLookup('bart@fullcontact'); 53 | $this->assertEquals(422, $result['status']); 54 | $this->assertRegExp('/invalid/i', $result['message']); 55 | } 56 | 57 | public function testDoLookupPhone() 58 | { 59 | $result = $this->client_old->doLookup('3037170414', 'phone'); 60 | $this->assertArrayHasKey('status', $result); 61 | $this->assertEquals(200, $result['status']); 62 | $this->assertEquals('Lorang', $result['contactInfo']['familyName']); 63 | $this->assertGreaterThanOrEqual(11, count($result['socialProfiles'])); 64 | } 65 | 66 | public function testBadPhone() 67 | { 68 | $result = $this->client_old->doLookup('303717'); 69 | $this->assertEquals(422, $result['status']); 70 | $this->assertRegExp('/invalid/i', $result['message']); 71 | } 72 | 73 | 74 | public function testDoLookupTwitter() 75 | { 76 | $result = $this->client_old->doLookup('lorangb', 'twitter'); 77 | $this->assertArrayHasKey('status', $result); 78 | $this->assertEquals(200, $result['status']); 79 | $this->assertEquals('Lorang', $result['contactInfo']['familyName']); 80 | $this->assertGreaterThanOrEqual(11, count($result['socialProfiles'])); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /tests/NameTest.php: -------------------------------------------------------------------------------- 1 | 25 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 26 | */ 27 | 28 | class NameTest extends PHPUnit_Framework_TestCase 29 | { 30 | protected $name = null; 31 | 32 | public function setUp() 33 | { 34 | global $apikey; 35 | 36 | $this->name = new Services_FullContact_Name($apikey); 37 | 38 | parent::setUp(); 39 | } 40 | 41 | public function testFailAPIKey() 42 | { 43 | $brokenRequest = new Services_FullContact_Name('nope, no good'); 44 | 45 | $name = $brokenRequest->normalize('John'); 46 | $this->assertEquals('403', $name->status); 47 | $this->assertRegExp('/invalid/i', $name->message); 48 | } 49 | 50 | public function testNormalize() 51 | { 52 | $name = $this->name->normalizer('John'); 53 | $this->assertEquals('John', $name->nameDetails->givenName); 54 | $this->assertEquals('John', $name->nameDetails->fullName); 55 | 56 | $name = $this->name->normalizer('John Smith'); 57 | $this->assertEquals('John', $name->nameDetails->givenName); 58 | $this->assertEquals('Smith', $name->nameDetails->familyName); 59 | 60 | $name = $this->name->normalizer('John Michael Smith'); 61 | $this->assertEquals('John', $name->nameDetails->givenName); 62 | $this->assertEquals(1, count($name->nameDetails->middleNames)); 63 | $this->assertEquals('Smith', $name->nameDetails->familyName); 64 | 65 | $name = $this->name->normalizer('Mr. John Michael Smith'); 66 | $this->assertEquals('John', $name->nameDetails->givenName); 67 | $this->assertEquals(1, count($name->nameDetails->prefixes)); 68 | $this->assertEquals('John Michael Smith', $name->nameDetails->fullName); 69 | 70 | $name = $this->name->normalizer('Mr. John Michael Smith Jr.'); 71 | $this->assertEquals(1, count($name->nameDetails->prefixes)); 72 | $this->assertEquals(1, count($name->nameDetails->suffixes)); 73 | $this->assertEquals(0, count($name->nameDetails->nicknames)); 74 | 75 | $name = $this->name->normalizer('Mr. John (Johnny) Michael Smith Jr.'); 76 | $this->assertEquals(1, count($name->nameDetails->nicknames)); 77 | $this->assertEquals('John Michael Smith', $name->nameDetails->fullName); 78 | } 79 | 80 | public function testDeducer() 81 | { 82 | $name = $this->name->deducer('caseysoftware', 'username'); 83 | $this->assertEquals('Casey', $name->nameDetails->givenName); 84 | $this->assertEquals('Casey', $name->nameDetails->fullName); 85 | 86 | $name = $this->name->deducer('mike@example.com'); 87 | $this->assertEquals('Mike', $name->nameDetails->givenName); 88 | $this->assertEquals('Mike', $name->nameDetails->fullName); 89 | 90 | $name = $this->name->deducer('fake@example.com'); 91 | $this->assertEquals('Fake', $name->nameDetails->familyName); 92 | $this->assertEquals('Fake', $name->nameDetails->fullName); 93 | 94 | $name = $this->name->deducer('fake@example.com', 'email', 'uppercase'); 95 | $this->assertEquals('FAKE', $name->nameDetails->fullName); 96 | $this->assertEquals('FAKE', $name->nameDetails->familyName); 97 | } 98 | 99 | public function testSimilarity() 100 | { 101 | $result = $this->name->similarity('John', 'Johnathan'); 102 | $this->assertEquals('200', $result->status); 103 | $this->assertGreaterThan(0.8, $result->result->SimMetrics->jaroWinkler->similarity); 104 | 105 | $result = $this->name->similarity('John', 'Mike'); 106 | $this->assertEquals(0, $result->result->FullContact->BigramAnalysis->dice->similarity); 107 | 108 | $result = $this->name->similarity('Michelle', 'Michael'); 109 | $this->assertEquals('200', $result->status); 110 | $this->assertGreaterThan(0.9, $result->result->SimMetrics->jaroWinkler->similarity); 111 | $this->assertEquals(0.625, $result->result->SimMetrics->levenshtein->similarity); 112 | } 113 | } -------------------------------------------------------------------------------- /tests/PersonTest.php: -------------------------------------------------------------------------------- 1 | 25 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache 26 | */ 27 | 28 | class PersonTest extends PHPUnit_Framework_TestCase 29 | { 30 | protected $person = null; 31 | 32 | public function setUp() 33 | { 34 | global $apikey; 35 | 36 | $this->person = new Services_FullContact_Person($apikey); 37 | 38 | parent::setUp(); 39 | } 40 | 41 | public function testLookupByEmail() 42 | { 43 | $person = $this->person->lookupByEmail('bart@fullcontact.com'); 44 | 45 | $this->assertEquals('Bart', $person->contactInfo->givenName); 46 | $this->assertGreaterThan(5, count($person->contactInfo->websites)); 47 | $this->assertGreaterThan(5, count($person->socialProfiles)); 48 | } 49 | 50 | public function testLookupByPhone() 51 | { 52 | $person = $this->person->lookupByPhone('3037170414'); 53 | 54 | $this->assertEquals('Bart', $person->contactInfo->givenName); 55 | $this->assertGreaterThan(5, count($person->contactInfo->websites)); 56 | $this->assertGreaterThan(5, count($person->socialProfiles)); 57 | } 58 | 59 | public function testLookupByTwitter() 60 | { 61 | $person = $this->person->lookupByTwitter('github'); 62 | 63 | $this->assertEquals('GitHub', $person->contactInfo->fullName); 64 | $this->assertEquals(5, count($person->socialProfiles)); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /tests/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ./ 5 | 6 | 7 | --------------------------------------------------------------------------------