PHP code example of kennetn / leadscore

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

    

kennetn / leadscore example snippets




ore = new LeadScore\LeadScore(API_KEY);

$stages = $LeadScore->stages->view();



{
    "leadscore": "^4.0"
    }
}



$stages = $LeadScore->stages->view();



$owners = $LeadScore->owners->view();



$segments = $LeadScore->segments->view();



$fields = $LeadScore->lead->fields();



/**
 * $fields = [
 *     'email'              => '[email protected]', // Email address
 *     'full_name'          => 'John Doe',         // Full name (Converts the name into first and last name)
 *     'first_name'         => 'John',             // First name
 *     'last_name'          => 'Doe',              // Last name
 *     'gender'             => 'MALE',             // Gender ('FEMALE', 'MALE' OR 'UNKNOWN')
 *     'title'              => 'Customer',         // Title
 *     'company'            => 'LeadScore App',    // Company
 *     'address'            => 'Bredgade 1',       // Address
 *     'zip'                => '7400',             // Zip code
 *     'city'               => 'Herning',          // City
 *     'country'            => 'Denmark',          // Country
 *     'phone'              => '12345678',         // Phone
 *     'phone_country_code' => '45',               // Phone country code
 *     'description'        => 'Lorem ipsum',      // Description
 *     '42'                 => '1.000,- DKK'       // Customfield "Budget" with customfield ID '42'
 * ];
 */
$response = $LeadScore->lead->add($fields, $stage_id = null, $owner_id = null, $segment_id = null, $sync = null);

setcookie('__lsk', $response['lead_key'], strtotime('+1 year'), '/'); // Save for one year



/**
 * $leads = [											// One or more leads with either ID, key or email
 *     [
 *         'id' => 42                                   // Lead ID
 *     ],
 *     [
 *         'key' => '8001083940a98db179c0473d9bc75ccf'  // Lead key
 *     ],
 *     [
 *         'email' => '[email protected]'                // Lead email address
 *     ]
 * ];
 *
 * $stage_id = 42;
 */
 $result = $LeadScore->lead->stage($leads, $stage_id); // ['leads' => 3, 'edited' => 3, 'same' => 0]



/**
 * $leads = [											// One or more leads with either ID, key or email
 *     [
 *         'id' => 42                                   // Lead ID
 *     ],
 *     [
 *         'key' => '8001083940a98db179c0473d9bc75ccf'  // Lead key
 *     ],
 *     [
 *         'email' => '[email protected]'                // Lead email address
 *     ]
 * ];
 *
 * $segment_id = 42;
 */
 $result = $LeadScore->lead->addToSegment($leads, $segment_id); // ['leads' => 3, 'changed' => 3, 'same' => 0]



/**
 * $leads = [											// One or more leads with either ID, key or email
 *     [
 *         'id' => 42                                   // Lead ID
 *     ],
 *     [
 *         'key' => '8001083940a98db179c0473d9bc75ccf'  // Lead key
 *     ],
 *     [
 *         'email' => '[email protected]'                // Lead email address
 *     ]
 * ];
 *
 * $segment_id = 42;
 */
 $result = $LeadScore->lead->removeFromSegment($leads, $segment_id); // ['leads' => 3, 'changed' => 3, 'same' => 0]



/**
 * $html                    = '<a href="leadscoreapp.dk">Klik her</a>';
 * $domains                 = ['leadscoreapp.dk'];
 * $key                     = '8001083940a98db179c0473d9bc75ccf';
 * $googleAnalyticsCampaign = 'leadscore';
 */
$html = $LeadScore->lead->applyTrackingCodes($html, $domains, $key, $googleAnalyticsCampaign);



/**
 * $name     = 'Lorem ipsum';
 * $slug     = 'lorem-ipsum';
 * $dealMax  = 42;
 * $statusId = 42;
 */
$result = $LeadScore->deals->addProduct($name, $slug, $dealMax = null, $statusId = null);



/**
 * $leads          = [                                    // One or more leads with either ID, key or email
 *     [
 *         'id'    => 42,                                 // Lead ID
 *     ],
 *     [
 *         'key'   => '8001083940a98db179c0473d9bc75ccf', // Lead key
 *     ],
 *     [
 *         'email' => '[email protected]',                 // Lead email address
 *     ]
 * ];
 * $userId         = 42;                                  // User ID
 * $dealProducts   = [                                    // One or more products with either ID or slug
 *     [
 *         'id'   => 42,                                  // Deal product ID
 *     ],
 *     [
 *         'slug' => 'lorem_ipsum',                       // Deal product ID
 *     ]
 * ];
 * $saleValue      = 1337;                                // Sale value
 * $name           = 'Lorem ipsum';                       // Deal name
 * $note           = 'Lorem ipsum dolor sit amet';        // Deal note
 * $internalNote   = 'Lorem ipsum dolor sit amet';        // Internal note
 * $statusId       = 42;                                  // Deal status ID
 * $fields         = [									  // One or more deal custom field values
 *     42 => 'Foo',										  // Lead deal field ID => Value
 *     43 => 'Bar'
 * ];
 */
$result = $LeadScore->deals->addToLead($leads, $userId, $dealProducts, $saleValue, $name, $note = null, $internalNote = null, $statusId = null, $fields = []);