Esempio n. 1
0
 private static function _readUrl($url)
 {
     $options = array(CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
     $data = ComScriptCURL::readUrl($url, null, array(), '', $options);
     $dom = new simple_html_dom();
     $dom->load($data);
     return $dom;
 }
Esempio n. 2
0
 private static function _postJson($url, $data)
 {
     $extraOptions = array(CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $data, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Content-Length: ' . strlen($data), 'MAGE_API:' . self::$_api['token']));
     $result = ComScriptCURL::readUrl($url, null, array(), '', $extraOptions);
     $result = json_decode($result, true);
     if (isset($result['token']) && ($token = trim($result['token'])) !== '') {
         self::$_api['token'] = $token;
         //return $result;
     } else {
         $result = null;
     }
     return $result;
 }
Esempio n. 3
0
 private static function _postJson($url, $data, $preFix = '', $debug = false)
 {
     self::_log('CURL to url: ' . $url, __CLASS__ . '::' . __FUNCTION__, $preFix);
     $extraOptions = array(CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $data, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Content-Length: ' . strlen($data), 'MAGE_API:' . self::$_api['token']));
     self::_log('With params: ' . $data, '', $preFix . self::TAB);
     $result = ComScriptCURL::readUrl($url, null, array(), '', $extraOptions);
     self::_log('Got Result: ', '', $preFix . self::TAB);
     self::_log(str_replace("\n", "\n" . $preFix . self::TAB . self::TAB, print_r($result, true)), '', $preFix . self::TAB . self::TAB);
     $result = json_decode($result, true);
     if (isset($result['token']) && ($token = trim($result['token'])) !== '') {
         self::$_api['token'] = $token;
     }
 }
Esempio n. 4
0
 /**
  * (non-PHPdoc)
  * @see CourierConn::removeManifest()
  */
 public function removeManifest($manifestId)
 {
     list($apiUrl, $apiKey, $accId) = $this->_getAPIInfos();
     $url = str_replace('{method}', 'fastlabel/removemanifest', trim($apiUrl));
     $params = array('api_key' => trim($apiKey), 'UserID' => trim($accId), 'ManifestID' => trim($manifestId));
     $result = $this->_getJsonResult(ComScriptCURL::readUrl($url, ComScriptCURL::CURL_TIMEOUT, $params));
     return $this;
 }