Пример #1
0
 /**
  * Allow clients to test authentication.
  * @return mixed response from the API call*/
 public function getAuthentications()
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/authentications';
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //append custom auth authorization headers
     CustomAuthUtility::appendCustomAuthParams($request);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 401) {
         throw new APIException('You are not authenticated', 401, $response->body);
     } else {
         if ($response->code == 403) {
             throw new APIException('This action needs a valid WSSE header', 403, $response->body);
         } else {
             if ($response->code == 400) {
                 throw new APIException('Http bad request', 400, $response->body);
             } else {
                 if ($response->code < 200 || $response->code > 206) {
                     //[200,206] = HTTP OK
                     throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                 }
             }
         }
     }
     return $response->body;
 }
Пример #2
0
 /**
  * Allow clients to test authentication.
  * @return mixed response from the API call*/
 public function getAuthentications()
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/authentications';
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'X-API-TOKEN' => $this->xAPITOKEN);
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 403) {
         throw new APIException('User not authorized to perform the operation', 403);
     } else {
         if ($response->code < 200 || $response->code > 206) {
             //[200,206] = HTTP OK
             throw new APIException("HTTP Response Not OK", $response->code);
         }
     }
     return $response->body;
 }
 /**
  * Perform a BIN (Bank Identification Number) or IIN (Issuer Identification Number) lookup. See: https://www.neutrinoapi.com/api/bin-lookup/
  * @param  string          $binNumber       Required parameter: The BIN or IIN number (the first 6 digits of a credit card number)
  * @param  string|null     $customerIp      Optional parameter: Pass in a customers remote IP address. The API will then determine the country of the IP address and match it against the BIN country. This feature is designed for fraud prevention and detection checks.
  * @return mixed response from the API call*/
 public function bINLookup($binNumber, $customerIp = NULL)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/bin-lookup';
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($queryBuilder, array('user-id' => $this->userId, 'api-key' => $this->apiKey));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare parameters
     $parameters = array('bin-number' => $binNumber, 'output-case' => 'camel', 'customer-ip' => $customerIp);
     //prepare API request
     $request = Unirest::post($queryUrl, $headers, $parameters);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code, $response->body);
     }
     return $response->body;
 }
Пример #4
0
 /**
  * TODO: type endpoint description here
  * @return mixed response from the API call*/
 public function getAccount()
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/me';
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'Authorization' => sprintf('Bearer %1$s', Configuration::$oAuthAccessToken));
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 404) {
         throw new APIException('UserNotFound', 404, $response->body);
     } else {
         if ($response->code < 200 || $response->code > 206) {
             //[200,206] = HTTP OK
             throw new APIException("HTTP Response Not OK", $response->code, $response->body);
         }
     }
     return $response->body;
 }
 /**
  * TODO: type endpoint description here
  * @return mixed response from the API call*/
 public function getStatsForSpecifiedChain()
 {
     //the base uri for api requests
     $queryBuilder = Configuration::BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/api/ethereum/api/';
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code);
     }
     return $response->body;
 }
Пример #6
0
 /**
  * `Sending Mails` – This API is used for sending emails. Pepipost supports REST as well JSON formats for the input. This is JSON API.
  * @param  Emailv1     $data     Required parameter: Data in JSON format
  * @return mixed response from the API call*/
 public function sendJson($data)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/api/web.send.json';
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8');
     //prepare API request
     $request = Unirest::post($queryUrl, $headers, json_encode($data));
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code, $response->body);
     }
     return $response->body;
 }
Пример #7
0
 /**
  * Download the latest translation package. If a language is provided, only the translation package of that language is returned. You must have given a /package call beforehand and wait until the packaging status is 'completed'.
  * @param  int        $id           Required parameter: Project ID
  * @param  string     $language     Required parameter: Optional language code. If you need, you can download the translation of only a specific language.
  * @return string response from the API call*/
 public function download($id, $language = null)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/projects/{id}/download/{language}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('id' => $id, 'language' => $language));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Authorization' => sprintf('Bearer %1$s', Configuration::$oAuthAccessToken));
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 402) {
         throw new APIException('ProjectNotLaunchedYet', 402, $response->body);
     } else {
         if ($response->code == 404) {
             throw new APIException('TranslationPackageNotFound', 404, $response->body);
         } else {
             if ($response->code < 200 || $response->code > 206) {
                 //[200,206] = HTTP OK
                 throw new APIException("HTTP Response Not OK", $response->code, $response->body);
             }
         }
     }
     return $response->body;
 }
 /**
  * TODO: type endpoint description here
  * @param  string     $addrs     Required parameter: TODO: type description here
  * @return mixed response from the API call*/
 public function createGetUnspentTransactionOutputsForMultipleAddresses($addrs)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/api/digibyte/api/utxo';
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($queryBuilder, array('addrs' => $addrs));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare API request
     $request = Unirest::post($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code);
     }
     return $response->body;
 }
 /**
  * Send a unique security code to any mobile device via SMS. See: https://www.neutrinoapi.com/api/sms-verify/
  * @param  string          $number            Required parameter: The phone number to send a verification code to
  * @param  int|null        $codeLength        Optional parameter: The number of digits to use in the security code (must be between 4 and 12)
  * @param  string|null     $countryCode       Optional parameter: ISO 2-letter country code, assume numbers are based in this country. If not set numbers are assumed to be in international format (with or without the leading + sign)
  * @param  string|null     $languageCode      Optional parameter: The language to send the verification code in, available languages are: de - German, en - English, es - Spanish, fr - Fench, it - Italian, pt - Portuguese, ru - Russian
  * @param  int|null        $securityCode      Optional parameter: ass in your own security code. This is useful if you have implemented TOTP or similar 2FA methods. If not set then we will generate a secure random code (only numerical security codes are currently supported)
  * @return mixed response from the API call*/
 public function sMSVerify($number, $codeLength = NULL, $countryCode = NULL, $languageCode = NULL, $securityCode = NULL)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/sms-verify';
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($queryBuilder, array('user-id' => $this->userId, 'api-key' => $this->apiKey));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare parameters
     $parameters = array('number' => $number, 'output-case' => 'camel', 'code-length' => null != $codeLength ? $codeLength : 5, 'country-code' => $countryCode, 'language-code' => null != $languageCode ? $languageCode : 'en', 'security-code' => $securityCode);
     //prepare API request
     $request = Unirest::post($queryUrl, $headers, $parameters);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code, $response->body);
     }
     return $response->body;
 }
Пример #10
0
/* Regulation Flow:
  listZipCodes -> createRegulationAddress -> uploadProofOfAddress -> Is Address Valid ->requestAddressVerification 
  -> linkAddress -> Unlink Address -> listRegulationAddress-> Delete Address 

/* Operations used:
    listZipCodes
    createRegulationAddress
    uploadProofOfAddress
    requestAddressVerification
    linkAddress
    Is Address Valid
    Unlink Address 
    listRegulationAddress x2
    Delete Address
*/
Unirest::auth(Configuration::$BasicAuthUserName, Configuration::$BasicAuthPassword);
$controller = new RegulationController();
$inventoryController = new InventoryController();
try {
    //Get Zip Code DEU
    $zipCodes = $controller->getZipcode('DEU', 0, 1, NULL);
    echo "<br/><br/><br/>";
    echo "<b>ZipCodes Response</b><br/>";
    echo "cityZipCodes: " . $zipCodes->cityZipCodes[0]->cityName . "<br/>";
    echo "zipCode: " . $zipCodes->cityZipCodes[0]->zipCode . "<br/>";
    $zipCode = $zipCodes->cityZipCodes[0]->zipCode;
    $zipCode = NULL;
    //Create Regulation Address
    echo "<br/><br/>";
    echo '<b>Create Regulation Address</b><br/>';
    $customerReference = 'address #123';
Пример #11
0
 /**
  * Update an account.
  * @param  AccountModel     $account            Required parameter: TODO: type description here
  * @param  int              $accountNumber      Required parameter: The account number
  * @return string response from the API call*/
 public function update($account, $accountNumber)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/accounts/{account_number}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('account_number' => $accountNumber));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'content-type' => 'application/json; charset=utf-8', 'X-API-TOKEN' => $this->xAPITOKEN);
     //prepare API request
     $request = Unirest::put($queryUrl, $headers, json_encode($account));
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 403) {
         throw new APIException('User not authorized to perform the operation', 403);
     } else {
         if ($response->code == 400) {
             throw new APIException('Request could not be understood', 400);
         } else {
             if ($response->code == 404) {
                 throw new APIException('Resource not found', 404);
             } else {
                 if ($response->code < 200 || $response->code > 206) {
                     //[200,206] = HTTP OK
                     throw new APIException("HTTP Response Not OK", $response->code);
                 }
             }
         }
     }
     return $response->body;
 }
Пример #12
0
 /**
  * Allow clients to get a specific region for a specific country
  * @param  string     $countryIso2       Required parameter: Country ISO2
  * @param  string     $regionHandle      Required parameter: Region handle
  * @return mixed response from the API call*/
 public function getRegionsByHandle($countryIso2, $regionHandle)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/dids/location/countries/{country_iso2}/regions/{region_handle}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('country_iso2' => $countryIso2, 'region_handle' => $regionHandle));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //append custom auth authorization headers
     CustomAuthUtility::appendCustomAuthParams($request);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 401) {
         throw new APIException('You are not authenticated', 401, $response->body);
     } else {
         if ($response->code == 403) {
             throw new APIException('This action needs a valid WSSE header', 403, $response->body);
         } else {
             if ($response->code == 404) {
                 throw new APIException('Resource not found', 404, $response->body);
             } else {
                 if ($response->code == 400) {
                     throw new APIException('Http bad request', 400, $response->body);
                 } else {
                     if ($response->code < 200 || $response->code > 206) {
                         //[200,206] = HTTP OK
                         throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                     }
                 }
             }
         }
     }
     return $response->body;
 }
 /**
  * Lookup a Message by MDR
  * @param  string     $recordId      Required parameter: Unique MDR ID
  * @return string response from the API call
  * @throws APIException
  **/
 function getMessageLookup($recordId)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/messages/{record_id}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('record_id' => $recordId));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'Flowroute Messaging SDK 1.0');
     //prepare API request
     $request = Unirest::get($queryUrl, $headers, NULL, $this->username, $this->password);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code, $response->body);
     }
     return $response->body;
 }
 /**
  * Watermark one image with another image. See: https://www.neutrinoapi.com/api/image-watermark/
  * @param  string          $imageUrl          Required parameter: The URL to the source image
  * @param  string          $watermarkUrl      Required parameter: The URL to the watermark image
  * @param  string|null     $format            Optional parameter: The output image format, can be either png or jpg
  * @param  int|null        $height            Optional parameter: If set resize the resulting image to this height (preserving aspect ratio)
  * @param  int|null        $opacity           Optional parameter: The opacity of the watermark (0 to 100)
  * @param  string|null     $position          Optional parameter: The position of the watermark image, possible values are: center, top-left, top-center, top-right, bottom-left, bottom-center, bottom-right
  * @param  int|null        $width             Optional parameter: If set resize the resulting image to this width (preserving aspect ratio)
  * @return binary response from the API call*/
 public function imageWatermark($imageUrl, $watermarkUrl, $format = NULL, $height = NULL, $opacity = NULL, $position = NULL, $width = NULL)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/image-watermark';
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($queryBuilder, array('user-id' => $this->userId, 'api-key' => $this->apiKey));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0');
     //prepare parameters
     $parameters = array('image-url' => $imageUrl, 'watermark-url' => $watermarkUrl, 'format' => null != $format ? $format : 'png', 'height' => $height, 'opacity' => null != $opacity ? $opacity : 50, 'position' => null != $position ? $position : 'center', 'width' => $width);
     //prepare API request
     $request = Unirest::post($queryUrl, $headers, $parameters);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code, $response->body);
     }
     return $response->body;
 }
Пример #15
0
 /**
  * Get a list of comments belonging to this activity.
  * @param  int     $activityId     Required parameter: Activity ID
  * @param  int     $projectId      Required parameter: Project ID
  * @return mixed response from the API call*/
 public function getActivityComments($activityId, $projectId)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/projects/{projectId}/activities/{activityId}/comments';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('activityId' => $activityId, 'projectId' => $projectId));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'Authorization' => sprintf('Bearer %1$s', Configuration::$oAuthAccessToken));
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 404) {
         throw new APIException('ProjectActivityNotFound', 404, $response->body);
     } else {
         if ($response->code < 200 || $response->code > 206) {
             //[200,206] = HTTP OK
             throw new APIException("HTTP Response Not OK", $response->code, $response->body);
         }
     }
     return $response->body;
 }
Пример #16
0
 /**
  * Create a new Access Token.
  * @param  string        $accountNumber         Required parameter: Account Number
  * @param  TokenForm     $accessTokenForm       Required parameter: TODO: type description here
  * @return mixed response from the API call*/
 public function createAccessTokens($accountNumber, $accessTokenForm)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/accounts/{account_number}/access-tokens';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('account_number' => $accountNumber));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8');
     //prepare API request
     $request = Unirest::post($queryUrl, $headers, json_encode($accessTokenForm));
     //append custom auth authorization headers
     CustomAuthUtility::appendCustomAuthParams($request);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 401) {
         throw new APIException('You are not authenticated', 401, $response->body);
     } else {
         if ($response->code == 403) {
             throw new APIException('This action needs a valid WSSE header', 403, $response->body);
         } else {
             if ($response->code == 404) {
                 throw new APIException('Resource not found', 404, $response->body);
             } else {
                 if ($response->code == 400) {
                     throw new APIException('Http bad request', 400, $response->body);
                 } else {
                     if ($response->code < 200 || $response->code > 206) {
                         //[200,206] = HTTP OK
                         throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                     }
                 }
             }
         }
     }
     return $response->body;
 }
 /**
  * Return the sentiment of an English text supplied in an encoded form using key 'text'.
  * @param  string     $text     Required parameter: Supply the text to be classified.
  * @return mixed response from the API call*/
 public function createReturnEnglishGeneralSentimentEncodedForm($text)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/sentiment';
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'X-Mashape-Key' => $this->xMashapeKey);
     //prepare parameters
     $parameters = array('text' => $text);
     //prepare API request
     $request = Unirest::post($queryUrl, $headers, $parameters);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code);
     }
     return $response->body;
 }
Пример #18
0
 public static function generateAccessToken()
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/token';
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'Authorization' => sprintf('Basic %1$s', base64_encode(Configuration::$clientID . ':' . Configuration::$clientSecret)));
     //prepare parameters
     $parameters = array('grant_type' => 'client_credentials');
     //prepare API request
     $request = Unirest::post($queryUrl, $headers, $parameters);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code == 500) {
         throw new APIException('Authentication error', 500, $response->body);
     } else {
         if ($response->code < 200 || $response->code > 206) {
             //[200,206] = HTTP OK
             throw new APIException("HTTP Response Not OK", $response->code, $response->body);
         }
     }
     if (isset($response->body->error)) {
         throw new APIException($response->body->error->code, $response->body->error->http_code, $response->body->error->message);
     }
     if (!isset($response->body->access_token)) {
         throw new OAuthException('Access token is missing.');
     }
     Configuration::$oAuthAccessToken = $response->body->access_token;
     return $response->body->access_token;
 }
Пример #19
0
 /**
  * Download a given monthly call report using MTOM
  * @param  string     $fileName     Required parameter: The name of the report to download
  * @return binary response from the API call*/
 public function getCdrsFile($fileName)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/cdrs/cdrsfile/{fileName}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('fileName' => $fileName));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('User-Agent' => 'APIMATIC 2.0');
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code);
     }
     return $response->body;
 }
 /**
  * Show information on a specific country
  * @param  string     $countryCodeA3     Required parameter: The three letter identifier for the country
  * @return mixed response from the API call*/
 public function getCountry($countryCodeA3)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/inventory/country/{countryCodeA3}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('countryCodeA3' => $countryCodeA3));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare API request
     $request = Unirest::get($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code);
     }
     return $response->body;
 }
 /**
  * Extract HTML tag contents or attributes from complex HTML or XHTML content. See: https://www.neutrinoapi.com/api/html-extract-tags/
  * @param  string          $content         Required parameter: The HTML content. This can be either a URL to load HTML from or an actual HTML content string
  * @param  string          $tag             Required parameter: The HTML tag(s) to extract data from. This can just be a simple tag name like 'img' OR a CSS/jQuery style selector
  * @param  string|null     $attribute       Optional parameter: If set, then extract data from the specified tag attribute. If not set, then data will be extracted from the tags inner content
  * @param  string|null     $baseUrl         Optional parameter: The base URL to replace into realive links
  * @return mixed response from the API call*/
 public function hTMLExtract($content, $tag, $attribute = NULL, $baseUrl = NULL)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/html-extract-tags';
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($queryBuilder, array('user-id' => $this->userId, 'api-key' => $this->apiKey));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare parameters
     $parameters = array('content' => $content, 'output-case' => 'camel', 'tag' => $tag, 'attribute' => $attribute, 'base-url' => $baseUrl);
     //prepare API request
     $request = Unirest::post($queryUrl, $headers, $parameters);
     //and invoke the API call request to fetch the response
     $response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response Not OK", $response->code, $response->body);
     }
     return $response->body;
 }