PHP code example of yopify / yo-dev-php-sdk

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

    

yopify / yo-dev-php-sdk example snippets



use Yopify\Yo\Client;
$client = new Client();

$yoClient->authToken = 'YOUR-TOKEN-HERE'; // auth token can be found here: https://local.yopify.com/settings#/api

// OR

$yoClient->setBasicAuth('[email protected]', 'secret'); // You can use basic auth also

$isAuthenticated = $yoClient->ping(); // false if not authenticated, current timestamp if success


$event = $yoClient->getEvent(EVENT_ID);

$events = $client->getEvents(10, 1);

// Check for success
if (isset($events->meta)) {
    echo 'Current page: ', $events->meta->pagination->current_page, "\n";
    echo 'Total pages: ', $events->meta->pagination->total_pages, "\n";
    echo 'Page page: ', $events->meta->pagination->per_page, "\n";
    echo 'Total count: ', $events->meta->pagination->total, "\n";
}

$event = new Yopify\Yo\YoEvent();
$event->event_type_id = '1';
$event->unique_id1 = '10';
$event->unique_id2 = '1';
$event->title = 'This awesome product';
$event->first_name = 'Jon';
$event->last_name = 'snow';
$event->city = 'New York';
$event->province = 'XXXX';
$event->country = 'USA';
$event->url = 'https://example.com';
$event->message_template = '[FIRST-NAME] from [COUNTRY] just purchased [TITLE-WITH-LINK]';
$YoEvent = $yoClient->createEvent($event);

$YoEvent = $yoClient->getEvent(EVENT_ID);

if (isset($YoEvent->data)) {
    $YoEvent = $YoEvent->data;
    $YoEvent->province = "AAAA";

    $updatedEvent = $yoClient->updateEvent($YoEvent);
}

$deletedEvent = $yoClient->deleteEvent(20);
bash
$ composer