Example #1
0
 public static function connect($data)
 {
     // result from server
     $response = Laposta_Util::connect(array('url' => $data['url'], 'headers' => self::getHeaders(), 'api_key' => Laposta::getApiKey(), 'post' => $data['post'], 'method' => $data['method'], 'httpsDisableVerifyPeer' => Laposta::getHttpsDisableVerifyPeer()));
     // check for CURL error
     if ($response['error']) {
         throw new Laposta_Error('Connection error: ' . $response['error_msg'], $response['status'], $response['body']);
     }
     // decode JSON
     $result = self::decode($response);
     // check for API errors
     if ($response['status'] < 200 || $response['status'] >= 300) {
         throw new Laposta_Error('API error: ' . $result['error']['message'], $response['status'], $response['body'], $result);
     }
     return $result;
 }
Example #2
0
<?php

require_once '../../lib/Laposta.php';
Laposta::setApiKey("JdMtbsMq2jqJdQZD9AHC");
// initialize list with list_id
$list = new Laposta_List();
try {
    // create new list, insert info as argument
    // $result will contain een array with the response from the server
    $result = $list->create(array('name' => 'Testlijst', 'remarks' => 'Een lijst om mee te testen', 'subscribe_notification_email' => '*****@*****.**', 'unsubscribe_notification_email' => '*****@*****.**'));
    print '<pre>';
    print_r($result);
    print '</pre>';
} catch (Exception $e) {
    // you can use the information in $e to react to the exception
    print '<pre>';
    print_r($e);
    print '</pre>';
}
Example #3
0
<?php

require_once '../../../lib/Laposta.php';
Laposta::setApiKey('JdMtbsMq2jqJdQZD9AHC');
Laposta::setHttpsDisableVerifyPeer(true);
// initialize campaign object
$campaign = new Laposta_Campaign();
try {
    // get campaign content info, use campaign_id as argument
    // $result will contain een array with the response from the server
    $result = $campaign->get('pbrqulw2tc', 'content');
    print '<pre>';
    print_r($result);
    print '</pre>';
} catch (Exception $e) {
    // you can use the information in $e to react to the exception
    print '<pre>';
    print_r($e);
    print '</pre>';
}
Example #4
0
<?php

require_once '../../lib/Laposta.php';
Laposta::setApiKey('JdMtbsMq2jqJdQZD9AHC');
// initialize campaign
$campaign = new Laposta_Campaign();
try {
    // get all campaign from account
    // $result will contain een array with the response from the server
    $result = $campaign->all();
    print '<pre>';
    print_r($result);
    print '</pre>';
} catch (Exception $e) {
    // you can use the information in $e to react to the exception
    print '<pre>';
    print_r($e);
    print '</pre>';
}
Example #5
0
 public static function setHttpsDisableVerifyPeer($disable)
 {
     self::$httpsDisableVerifyPeer = $disable;
 }
Example #6
0
 private function formatBaseUrl()
 {
     $url = Laposta::getApiBase() . '/' . $this->getResource();
     return $url;
 }