Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- DEFINE('INEW_DATAMIXER_API_BASEURL', 'https://dev.skitto.com/inew_api/test/rest/');
- DEFINE('INEW_INT_HASH_KEY', '3D0FD055649155A8A8665D413B5AA133');
- DEFINE('REST_ACCESS_KEY', '1_clq8dg5qb4nu510high64b6eot');
- DEFINE('REQUEST_START', microtime(TRUE));
- $filename = "test.csv";
- global $log_file;
- $log_file = "log_file.txt";
- // $filename = "inactive_datamixer.csv";
- function inew_datamixer_api_call($method, $URL, $data = NULL, $api_name = '') {
- global $log_file;
- $api_call_status = '1';
- $ch = curl_init($URL);
- if (!empty($data)) {
- // $data=urldecode(http_build_query($data));
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
- }
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, '30');
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'accessKey:' . REST_ACCESS_KEY, 'x-auth-api-key:' . INEW_INT_HASH_KEY));
- $result = curl_exec($ch);
- $inew_time = (microtime(TRUE) - REQUEST_START);
- if ($errno = curl_errno($ch)) {
- $result = json_encode(array('url' => $URL, 'request' => $data, 'method' => $method, 'response' => $errno . ':' . curl_error($ch)));
- // $this->inew_log($result);
- $api_call_status = '0';
- }
- curl_close($ch);
- // $this->inew_log(json_encode(array('url' => $URL, 'request' => $data, 'method' => $method, 'response' => $result)));
- if (!empty($api_name)) {
- /* Logging api access */
- $log = array(
- 'api_name' => !empty($api_name) ? $api_name : '',
- 'status' => $api_call_status,
- 'inew_time' => $inew_time
- );
- $file = fopen($log_file,"a+");
- fwrite($file,implode("|",$log).PHP_EOL);
- fclose($file);
- // write_api_access($log);
- /* Loggin end *//* Logging api access */
- }
- return $result;
- }
- function deactivate_auto_renew($subscriber_id, $tarrif_id) {
- $URL = INEW_DATAMIXER_API_BASEURL . "subscriptions/$subscriber_id/activePlan/$tarrif_id/deactivate";
- $inew_resp = inew_datamixer_api_call("PUT", $URL, '', 'deactiveAutoRenew');
- $resp = json_decode($inew_resp);
- if ($resp->responseCode == 0)
- return true;
- return false;
- }
- // $csv = array_map('str_getcsv', file($filename));
- deactivate_auto_renew($subscriber_id, $tarrif_id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement