PHP code example of upviral / php-sdk

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

    

upviral / php-sdk example snippets


composer 



$apiKey = "<Your API Key>";
$upviral = new Upviral\SDK($apiKey);

$campaigns = $upviral->getCampaigns();
var_dump($campaigns);

$customFields = $upviral->geCustomFields('<campaign id>');
var_dump($customFields);

$contact = new \Upviral\Entity\Contact();
$contact->name = '<Name>';
$contact->email = '<Email';
$contact->campaigns = '<campaign id>';
$contact->referred_by = '<Referal code>';
$contact->custom_fields = ['custom_field_1'=>'value'];
$res = $upviral->addContact($contact);
var_dump($res);

$contact = $upviral->getContact('<lead id>', '<campaign id>');
var_dump($contact);

$contact = $upviral->getContact('<email id>', '<campaign id>');
var_dump($contact);

$contacts = $upviral->getContacts('<campaign id>');
var_dump($contacts);

$contacts = $upviral->getContacts('<campaign id>', ['operator'=>'<operator>', 'points'=>'<ponts>']);
// For example 
// $contacts = $upviral->getContacts('<campaign id>', ['operator'=>'>', 'points'=>'100']);
var_dump($contacts);

$res = $upviral->addPoints('<lead/contact id>', '<campaign id>', <points>);
var_dump($res);