/**
  * @param Mailxpert $mailxpert
  * @param string    $name
  *
  * @return \Mailxpert\MailxpertResponse
  * @throws MailxpertSDKException
  */
 public static function post(Mailxpert $mailxpert, $name)
 {
     $response = $mailxpert->sendRequest('POST', 'contact_lists', [], null, json_encode(['name' => $name]));
     if (!$response->getHeader('Location')) {
         throw new MailxpertSDKException('An error occured during the Contact list creation.');
     }
     return $response;
 }
 /**
  * @param  Mailxpert $mailxpert
  * @param  string    $id
  *
  * @return \Mailxpert\MailxpertResponse
  * @throws MailxpertSDKResponseException
  */
 public static function delete(Mailxpert $mailxpert, $id)
 {
     $response = $mailxpert->sendRequest('DELETE', sprintf('custom_fields/%s', $id));
     if (!$response->isHttpResponseCodeOK()) {
         throw new MailxpertSDKResponseException($response, 'An error occured during the CustomField deletion.');
     }
     return $response;
 }
 /**
  * @param Mailxpert $mailxpert
  * @param string    $customFieldId
  * @param array     $params
  *
  * @return \Mailxpert\MailxpertResponse
  * @throws MailxpertSDKException
  */
 public static function post(Mailxpert $mailxpert, $customFieldId, array $params)
 {
     $response = $mailxpert->sendRequest('POST', sprintf('custom_fields/%s/choices', $customFieldId), [], null, json_encode($params));
     if (!$response->getHeader('Location')) {
         throw new MailxpertSDKException('An error occured during the Contactfield Choice creation.');
     }
     return $response;
 }
Example #4
0
<?php

/**
 * Example of OAuth manipulation.
 *
 * Change your own settings in common/_parameters.php
 */
require_once 'common/bootstrap.php';
use Mailxpert\Mailxpert;
$mailxpert = new Mailxpert(['app_id' => $appId, 'app_secret' => $appSecret, 'api_base_url' => 'http://api.mailxpert.dev/app_dev.php', 'oauth_base_url' => 'http://app.mailxpert.dev/app_dev.php']);
session_start();
if (isset($_SESSION['access_token'])) {
    $mailxpert->setAccessToken($_SESSION['access_token']);
}
$page = isset($_GET['p']) ? $_GET['p'] : '';
switch ($page) {
    case 'contactlists':
        require 'contactlists.php';
        break;
    case 'refresh_token':
        require 'refreshtoken.php';
        break;
    default:
        if (isset($_SESSION['access_token'])) {
            require 'menu.php';
        } else {
            require 'login.php';
        }
        break;
}