public function VerifyToken(AuthInfo $authinfo) { $headers = array('Content-Type' => 'application/json', 'Authorization' => $authinfo->_token_type . ' ' . $authinfo->_id_token); $request = new Http_Request2('https://merchant-api.jet.com/api/authcheck/'); $request->setMethod(HTTP_Request2::METHOD_GET); $request->setHeader($headers); $request->setBody(""); $request->setConfig(array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE)); try { $response = $request->send(); //echo $response->getBody(); $bodyresponse = $response->getBody(); //$jsonresp = json_decode($bodyresponse); return true; } catch (HttpException $ex) { echo $ex; return false; } }
public function PutOrderComplete(AuthInfo $authinfo, $id, $ordeerdetails) { $headers = array('Content-Type' => 'application/json', 'Authorization' => $authinfo->_token_type . ' ' . $authinfo->_id_token); $request = new Http_Request2('https://merchant-api.jet.com/api/returns/' . $id . '/complete'); $request->setMethod(HTTP_Request2::METHOD_PUT); $request->setHeader($headers); $bodycontent = json_encode($ordeerdetails); $request->setBody($bodycontent); $request->setConfig(array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE)); try { $response = $request->send(); //echo $response->getBody(); $bodyresponse = $response->getBody(); $jsonresp = $bodyresponse; return $jsonresp; } catch (HttpException $ex) { echo $ex; return null; } }
public function Analyze() { $imageURL = $this->ImageURL; // This sample uses the HTTP_Request2 package. (for more information: http://pear.php.net/package/HTTP_Request2) require_once 'HTTP/Request2.php'; $headers = array('Content-Type' => 'application/json'); $query_params = array('subscription-key' => 'f2967b0e51bc4c848838814ae877780e', 'visualFeatures' => 'Categories, Description'); $request = new Http_Request2('https://api.projectoxford.ai/vision/v1/analyses'); $request->setMethod(HTTP_Request2::METHOD_POST); // Basic Authorization Sample // $request-setAuth('{username}', '{password}'); $request->setHeader($headers); $url = $request->getUrl(); $url->setQueryVariables($query_params); $request->setBody("{'Url':'{$imageURL}'}"); try { $response = $request->send(); return $response->getBody(); } catch (HttpException $ex) { return false; } }
public function GetTaxonomyNodeAttributes(AuthInfo $authinfo, $nodeid) { $headers = array('Content-Type' => 'application/json', 'Authorization' => $authinfo->_token_type . ' ' . $authinfo->_id_token); $request = new Http_Request2('https://merchant-api.jet.com/api/taxonomy/nodes/' . $nodeid . '/attributes'); $request->setMethod(HTTP_Request2::METHOD_GET); $request->setHeader($headers); $request->setBody(""); $request->setConfig(array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE)); try { $response = $request->send(); echo $response->getBody(); $bodyresponse = $response->getBody(); $jsonresp = json_decode($bodyresponse); //if( stripos($bodyresponse, 'iphone' ) ){ // echo 'found iphone'; //} return $jsonresp; } catch (HttpException $ex) { echo 'Exception caught : ' . $ex; return null; } }
echo "Size: " . $_FILES["file"]["size"] / 1024 . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"] . " <br />"; } } else { echo "Invalid file <br />"; } echo "---test emotion api from here---<br />"; // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/) require_once 'HTTP/Request2.php'; $request = new Http_Request2('https://api.projectoxford.ai/emotion/v1.0/recognize'); $url = $request->getUrl(); $headers = array('Content-Type' => 'application/octet-stream', 'Ocp-Apim-Subscription-Key' => '2607f8062fb3451e84de25a087b7d2e3'); $request->setHeader($headers); /* $parameters = array( // Request parameters //'faceRectangles' => '{string}', ); $url->setQueryVariables($parameters); */ $request->setMethod(HTTP_Request2::METHOD_POST); // Request body $request->setBody(fopen($_FILES["file"]["tmp_name"], 'r')); echo $request->getBody() . "<br/> item upon is request body<br/>"; try { $response = $request->send(); echo $response->getBody() . "<br/> item upon is response body<br/>"; } catch (HttpException $ex) { echo $ex . "<br/> ex <br/>"; }
<?php chdir('./includes/'); $imageURL = "http://tsuts.tskoli.is/2t/1803982879/vef2a3u/myndavefur/img/large/1092054380_6040129664.jpg"; // This sample uses the HTTP_Request2 package. (for more information: http://pear.php.net/package/HTTP_Request2) require_once 'HTTP/Request2.php'; $headers = array('Content-Type' => 'application/json'); $query_params = array('subscription-key' => 'f2967b0e51bc4c848838814ae877780e', 'visualFeatures' => 'Categories, Description'); $request = new Http_Request2('https://api.projectoxford.ai/vision/v1/analyses'); $request->setMethod(HTTP_Request2::METHOD_POST); // Basic Authorization Sample // $request-setAuth('{username}', '{password}'); $request->setHeader($headers); $url = $request->getUrl(); $url->setQueryVariables($query_params); $request->setBody("{'Url':'{$imageURL}'}"); try { $response = $request->send(); echo $response->getBody(); } catch (HttpException $ex) { echo $ex; }
<?php require_once 'HTTP/Request2.php'; require_once 'AuthAPI.php'; require_once 'TaxonomyAPI.php'; require_once 'ProductAPI.php'; require_once 'OrdersAPI.php'; require_once 'ReturnAPI.php'; $request = new Http_Request2('https://merchant-api.jet.com/api/token/'); $request->setMethod(HTTP_Request2::METHOD_POST); $headers = array('Content-Type' => 'application/json'); $request->setHeader($headers); $bodyvalue = '{ "user": "******", "pass": "******" }'; $request->setBody($bodyvalue); $request->setConfig(array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE)); try { //var_dump($request); $response = $request->send(); echo 'success' . $response->getBody(); } catch (HttpException $ex) { echo 'in exception'; echo $ex; }
<?php // This sample uses the HTTP_Request2 package. (for more information: http://pear.php.net/package/HTTP_Request2) require_once 'HTTP/Request2.php'; $headers = array('Content-Type' => 'application/json'); $query_params = array('subscription-key' => '4ad0d6534dc44dd7aa428fead63965a3', 'visualFeatures' => 'All'); $request = new Http_Request2('https://api.projectoxford.ai/emotion/v1.0/recognize'); $request->setMethod(HTTP_Request2::METHOD_POST); // Basic Authorization Sample // $request-setAuth('{username}', '{password}'); $request->setHeader($headers); $url = $request->getUrl(); $url->setQueryVariables($query_params); $request->setBody("{'Url':'http://www.lifed.com/wp-content/uploads/2014/10/smiling-woman.jpg'}"); try { $response = $request->send(); echo $response->getBody(); } catch (HttpException $ex) { echo $ex; }
// subscribe to get your key: https://www.projectoxford.ai/spellcheck //http://www.tinymce.com/wiki.php/Configuration:spellchecker_rpc_url if (isset($_POST['method'])) { $content = $_POST['text']; // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/) // added using `pear install HTTP_Request2` require_once 'HTTP/Request2.php'; $request = new Http_Request2('http://api.projectoxford.ai/text/v1.0/spellcheck'); $url = $request->getUrl(); $headers = array('Content-Type' => 'application/x-www-form-urlencoded', 'Ocp-Apim-Subscription-Key' => POXFORD_SPELLCHECK_KEY); $request->setHeader($headers); $parameters = array('mode' => 'proof'); $url->setQueryVariables($parameters); $request->setMethod(HTTP_Request2::METHOD_POST); // Request body $request->setBody('Text=' . urlencode($content)); try { $response = $request->send(); $r = $response->getBody(); // returns json $a = json_decode($r, true); // convert json to an associative array //convert the result to something tinymce spellchecker understands, //see http://www.tinymce.com/wiki.php/Configuration:spellchecker_rpc_url if (isset($a['spellingErrors'])) { $ret['words'] = array(); foreach ($a['spellingErrors'] as $value) { foreach ($value['suggestions'] as $suggestion) { $ret['words'][$value['token']][] = $suggestion['token']; } }
public function DeleteSKU(AuthInfo $authinfo, $sku, $oneprod) { $headers = array('Content-Type' => 'application/json', 'Authorization' => $authinfo->_token_type . ' ' . $authinfo->_id_token); $request = new Http_Request2('https://merchant-api.jet.com/api/merchant-skus/' . $sku . '/image'); $request->setMethod(HTTP_Request2::METHOD_DELETE); $request->setHeader($headers); $bodycontent = ""; $request->setBody($bodycontent); $request->setConfig(array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE)); try { $response = $request->send(); //echo $response->getBody(); $bodyresponse = $response->getBody(); $jsonresp = $bodyresponse; return $jsonresp; } catch (HttpException $ex) { echo $ex; return null; } }