/** * Sanitizes a value of an argument (message or query one). * * @param string $value The value to sanitize. * * @return string The sanitized value. */ public static function sanitizeArgumentValue($value) { if (Communicator::isSeekableStream($value)) { return $value; } else { return (string) $value; } }
/** * Requests an access token from Instagram * @return string JSON Response */ public function requestAccessToken() { $url = parent::$_instagramOAuthUrl . self::$_instaTokenUrlPath; $Communicator = new Communicator($url, $this->getPostVars()); $Communicator->query(); return $jsonResponse = $Communicator->getResponse(); }
/** * Given a shorlink, returns the image source url. * @param string $url Instagram Short URL * @return string Image source url */ public static function getImageFromUrl($url) { $params = array('url' => $url); $url = self::$endpointUrl; $communicator = new Communicator($url, $params); $communicator->query(); $response = $communicator->getResponse(); $data = json_decode($response); $imgSrc = $data->link; return $imgSrc; }
/** * Sends the query and returns the result * @param string $reqType Request type to use, for example "GET", "POST" * @return string JSON Response */ public function query($reqType = '', $count = 30) { $url = $this->requestUrl; $Communicator = new Communicator($url, $this->params); if ($reqType != '') { $Communicator->setCustomRequest($reqType); } $Communicator->query(); $json = $Communicator->getResponse(); $this->processResponse($json); $this->responseWalk(); return $this->response; //$json2 = json_encode($this->response); //var_dump($json2);exit; return $json; }
public function getCodes($code_type = NULL, array $tax_request_options = NULL) { if ($code_type !== NULL) { $this->setCodeType($code_type); } if ($tax_request_options !== NULL && is_array($tax_request_options)) { $this->setTaxRequestOptions($tax_request_options); } $data = array('CodeType' => $this->code_type === NULL ? '' : $this->code_type, 'Options' => array()); if ($this->tax_request_options) { foreach ($this->tax_request_options as $tax_request_option) { $data['Options'][] = array('TaxRequestOption' => array('Key' => $tax_request_option->getKey(), 'Value' => $tax_request_option->getValue())); } } $communicator = new Communicator($this->taxify); $return = $communicator->call(self::CALL_GET_CODES, $data); $this->codes = array(); $this->setCodeType($return['CodeType']); foreach ($return['Codes'] as $code) { $c = new Code($code); $this->codes[] = $c; } return $this->codes; }
public function verifyAddress() { if ($this->taxify === NULL) { throw new Exception(self::ERROR_TAXIFY_OBJ_NOT_PRESENT); } $this->is_validated = FALSE; $this->validation_status = NULL; $this->original_address = clone $this; $this->original_address->clearObjectProperties(); $communicator = new Communicator($this->taxify); $return = $communicator->call(self::CALL_VERIFY_ADDRESS, $this->toArray()); $this->validation_status = $return['Address']['ValidationStatus']; $this->is_validated = $this->validation_status == self::VALIDATION_SUCCESS; $this->setFirstName($return['Address']['FirstName'])->setLastName($return['Address']['LastName'])->setCompany($return['Address']['Company'])->setStreet1($return['Address']['Street1'])->setStreet2($return['Address']['Street2'])->setCity($return['Address']['City'])->setCounty($return['Address']['County'])->setRegion($return['Address']['Region'])->setPostalCode($return['Address']['PostalCode'])->setCountry($return['Address']['Country'])->setEmail($return['Address']['Email'])->setPhone($return['Address']['Phone'])->setResidentialOrBusinessType($return['Address']['ResidentialOrBusinessType']); /** TODO: Check for AddressSuggestions (need to find an address where this is populated so I can test it first) */ }
<?php /** api.php This file loads libs and processes the client request by handling Communicator object. */ // load all the stuff require_once 'config.php'; require_once 'include/class-communicator.php'; require_once 'include/class-user.php'; require_once 'include/class-message.php'; require_once 'include/class-conversation.php'; // merge POST and GET into one array $request = array_merge($_POST, $_GET); // create Communicator base object $JAC = new Communicator($request); // handle the requested action $JAC->handleAction($request['action']); // send the JSON answer based on action request $JAC->replyJSON();
/** * [UpdateListWithFolder - assign list to different folder] * @param [int] $ListID * @param [string] $NewListName * @param [string] $NewListDescription * @param [int] $NewFolderID */ public function UpdateListWithFolder($ListID, $NewListName, $NewListDescription, $NewFolderID) { $params = "&ListID={$ListID}&NewListName={$NewListName}&NewListDescription={$NewListDescription}&NewFolderID={$NewFolderID}"; return parent::execute(__FUNCTION__, $params); }
/** * Get Subscriber * @param String $email * A valid email addresses is required to query the database. */ public function GetSubscriber($email) { $params = "&email={$email}"; return parent::execute(__FUNCTION__, $params); }
public function notifications() { // Check if the notifications-app is available, if so, redirect there if (file_exists(DIR_HOME . 'apps/notifications/information.php')) { return $this->forward('app/notifications'); } $json = array(); // Version check $latestVersion = Communicator::getVersion(); if ($latestVersion != VERSION) { $json['version'] = array('url' => 'http://www.sumostore.net/download', 'text' => '<i class="fa fa-exclamation-triangle"></i><strong>Download V' . $latestVersion . '</strong><span class="date">' . Formatter::dateTime(time()) . '</span>'); } // Latest customer $json['customer']['data'] = Database::query("SELECT firstname, middlename, lastname, gender, customer_id, date_added FROM PREFIX_customer ORDER BY date_added DESC LIMIT 1")->fetch(); if (empty($json['customer']['data'])) { unset($json['customer']); } else { $json['customer'] = array('url' => $this->url->link('sale/customer/update', 'customer_id=' . $json['customer']['data']['customer_id'], 'SSL'), 'text' => Language::getVar('SUMO_ADMIN_LATEST_CUSTOMER_REGISTERED', array($json['customer']['data']['gender'] == 'm' ? 'male' : 'female', $json['customer']['data']['firstname'] . (!empty($json['customer']['data']['middlename']) ? ' ' . $json['customer']['data']['middlename'] . ' ' : ' ') . $json['customer']['data']['lastname'], Formatter::dateTime($json['customer']['data']['date_added'], false)))); } // Latest order $json['order']['data'] = Database::query("SELECT order_id, order_date, order_status FROM PREFIX_orders ORDER BY order_date DESC LIMIT 1")->fetch(); if (empty($json['order']['data'])) { unset($json['order']); } else { $json['order'] = array('url' => $this->url->link('sale/order/info', 'order_id=' . $json['order']['data']['order_id'], 'SSL'), 'text' => Language::getVar('SUMO_ADMIN_LATEST_ORDER', array(Formatter::dateTime($json['order']['data']['order_date'], false)))); } // Latest return $json['return']['data'] = Database::query("SELECT return_id, date_added FROM PREFIX_return ORDER BY date_added DESC LIMIT 1")->fetch(); if (empty($json['return']['data'])) { unset($json['return']); } else { $json['return'] = array('url' => $this->url->link('sale/return/info', 'return_id=' . $json['return']['data']['return_id'], 'SSL'), 'text' => Language::getVar('SUMO_ADMIN_LATEST_RETURN', array(Formatter::dateTime($json['return']['data']['date_added'], false)))); } $this->response->setOutput(json_encode($json)); }
public function commitTax() { if (empty($this->document_key)) { throw new Exception(self::ERROR_NO_DOCUMENT_KEY); } $data = array('DocumentKey' => Taxify::toString($this->document_key), 'CommitedDocumentKey' => Taxify::toString($this->committed_document_key)); $communicator = new Communicator($this->taxify); $return = $communicator->call(self::CALL_COMMIT_TAX, $data); $tax_response = new TaxResponse(); $tax_response->setResponseStatus(1); $tax_response->setExtendedProperties($return['ExtendedProperties']); return $tax_response; }