PHP vCard Library: Import and export contact lists in vCard format

Recommend this page to a friend!
  Info   Example   View files (17)   Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-06-05 (2 months ago) Not enough user ratingsTotal: 130 This week: 3All time: 9,059 This week: 73
Version License PHP version Categories
imexvcard 1.0.1Freely Distributable5PHP 5, Files and Folders, User Manage..., P...
Description Author

This package can be used to import and export contact lists in vCard format.

It can create a new contact list from scratch and export it in vCard format - .vcf - compliant with the version 3.0 of the format specification (RFC 2426).

The package can also import an existing VCF file and makes it available to the PHP applications as an iterator that returns the details of each contact that was found in the vCard file. The package supports vCard format version 2.1 and 3.0.

Recommendations

What is the best PHP vcard export and import class?
Parse vcard values in mobile contact list

Picture of Stefan Kientzler
  Performance   Level  
Name: Stefan Kientzler is available for providing paid consulting. Contact Stefan Kientzler .
Classes: 11 packages by
Country: Germany Germany
Age: 52
All time rank: 2165137 in Germany Germany
Week rank: 6 1 in Germany Germany
Innovation award
Innovation award
Nominee: 6x

Winner: 3x

Details

PHP vCard Library: Import and export contacts in vCard format

Latest Stable Version License Minimum PHP Version

This package can be used to import and export contact lists in vCard format.

It can create a new contact list from scratch and export it in vCard format - .vcf - compliant with the version 3.0 of the format specification (RFC 2426).

The package can also import an existing VCF file and makes it available to the PHP applications as an iterator that returns the details of each contact that was found in the vCard file. The package supports vCard format version 2.1 and 3.0.

Installation

You can download the Latest release version from PHPClasses.org

Usage

Import VCF

	// create object and read file
	$oVCard = new VCard();
	$iContactCount = $oVCard->read($strFilename);
	for ($i = 0; $i < $iContactCount; $i++) {
		// iterate to importetd contacts
		$oContact = $oVCard->getContact($i);
		$strName = $oContact->getName();
        // ... read more properties
        
		// iterating through all addresses
		$iCount = $oContact->getAddressCount();
		for ($j = 0; $j < $iCount; $j++) {
			$oAddress = $oContact->getAddress($j);
			$strStr = $oAddress->getStr();
            // ... read more properties
		}

		// phonenumbers
		$iCount = $oContact->getPhoneCount();
		for ($j = 0; $j < $iCount; $j++) {
			$aPhone = $oContact->getPhone($j);
			$strType = $aPhone['strType'];
            $strPhone = $aPhone['strPhone'];
		}

		$iCount = $oContact->getEMailCount();
		for ($j = 0; $j < $iCount; $j++) {
			$strMail = $oContact->getEMail($j);
		}
	}

Export VCF

	// create object
	$oVCard = new VCard();

	// just create new contact
	$oContact = new VCardContact();
	$oContact->setName('von Flake', 'Wiki');
	$oContact->setOrganisation('Company 4711');

    // HOME address
	$oAddress = new VCardAddress();
	$oAddress->setType(VCard::HOME);
	$oAddress->setStr('Bärenweg. 4');
    // ... set more properties of oAddress
	$oContact->addAddress($oAddress, true);

    // WORK address
	$oAddress = new VCardAddress();
	$oAddress->setType('WORK');
	$oAddress->setStr('Companystr. 8');
    // ... set more properties of oAddress
	$oContact->addAddress($oAddress, false);

    // phones
	$oContact->addPhone('01234 5678', VCard::HOME, false);
	$oContact->addPhone('0123 89765456', VCard::CELL, true);
	$oContact->addPhone('01234 98356', VCard::WORK, false);
	
    // e-mails
	$oContact->addEMail('private@web.de', true);
	$oContact->addEMail('president@club.de', false);
	$oContact->addEMail('work@company.de', false);
	
	// insert contact
	$oVCard->addContact($oContact);
    
    // ... may continue with further contacts

	// and write to file
	$oVCard->write('test.vcf', false);    

  Files  
File Role Description
doc (1 file)
images (4 files)
SKien (1 directory)
autoloader.php Aux. Auxiliary script
blobPortrait.php Aux. Auxiliary script
ExportTest.php Example Test for Export vCard
ImportSelect.php Aux. form to open vCard
ImportTest.php Example Test for Import vCard
LICENSE Lic. License
readme.md Doc. readme
test.vcf Data sample vCard

  Files  /  doc  
File Role Description
   vCard-rfc2426.pdf Doc. RFC 2426 Specification

  Files  /  images  
File Role Description
   sample1.jpg Photo sample JPG image
   sample2.png Photo sample PNG image
   sample3.bmp Photo sample BMP image
   sample4.gif Photo sample GIF image

  Files  /  SKien  
File Role Description
VCard (4 files)

  Files  /  SKien  /  VCard  
File Role Description
   VCard.php Class Class source
   VCardAddress.php Class Class source
   VCardContact.php Class Class source
   VCardHelper.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:130
This week:3
All time:9,059
This week:73

For more information send a message to info at phpclasses dot org.