PHP code example of wildsurfer / infusionsoft-sync

1. Go to this page and download the library: Download wildsurfer/infusionsoft-sync 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/ */

    

wildsurfer / infusionsoft-sync example snippets




$result = $sync->push(...);

$failed = $result['fail']; // Array of failed contacts

if ($failed->count() > 0) {
    foreach ($failed->read() as $f) {
        echo $f->getErrorMessage();
    }
}

 php

use Wildsurfer\Infusionsoft;

$options = array(
    'appname' => 'myappname',
    'apikey' => 'asdU234YGUYG1234gjhg',
    'tags' => array(
        '1',
        '2',
        '3'
    ),
    'fields' = array(
        'Email',
        'FirstName',
        'LastName'
    )
);

$sync = new Sync($options);

$infusionsoftContacts = $sync->pull();

 php


$myUsers = ... // Fetch data from your storage

$toBeSyncedUsers = new ContactCollection();

foreach($myUsers as $user) {
    $array = someFunctionToMapYourFieldNamesToInfusionsoftFieldNames($user);
    $toBeSyncedUsers->create(new Contact($array));
}

$result = $sync->push($toBeSyncedUsers);

$created = $result['create']->read(); // Array of created contacts
$updated = $result['update']->read(); // Array of updated contacts
$failed = $result['fail']->read(); // Array of failed contacts
$skipped = $result['skip']->read(); // Array of skipped contacts

bash
$ cp infusionsoft.ini.dist infusionsoft.ini
$ vim infusionsoft.ini