Example #1
0
 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;
     }
 }
Example #2
0
 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;
     }
 }
Example #4
0
 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;
     }
 }
Example #5
0
        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/>";
}
Example #6
0
 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;
     }
 }
Example #7
0
<?php

/* Author: Gowtham */
require 'HTTP/Request2.php';
$url = 'http://www.results.manabadi.co.in/KJNTUBTECH11012012.aspx?htno=06331a0478';
$r = new Http_Request2($url);
$r->setMethod(HTTP_Request2::METHOD_GET);
$r->setHeader(array("Referer" => "http://www.results.manabadi.co.in/KakinadaJNTU-IIIB.Tech-IIsem-results-11012012.htm"));
$r->addCookie('__utma', '264667532.627952658.1331704468.1331704468.1331704468.1');
$r->addCookie('__utmc', '264667532');
$r->addCookie('__utmz', '264667532.1331704468.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)');
$r->addCookie('__utmb', '264667532');
//$response = $r->send();
//$page = $response->getBody();
$dom = new DOMDocument();
$page = "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN' 'http://www.w3.org/TR/REC-html40/loose.dtd'><html><body><br><table width='80%' cellpadding='0' cellspacing='0'><tr><th colspan='2' align='center'>Personal Information</th></tr><tr><td><b> Hall Ticket No </b></td><td>06331A0478</td></tr></table><br><table width='100%' cellpadding='0' cellspacing='0'><tr><th colspan='5' align='center'>Marks Details</th></tr><tr><td><b>Subject Code</b></td><td><b>Subject Name</b></td><td><b>Internal Marks</b></td><td><b>External Marks</b></td><td><b>Credits</b></td></tr><tr><td>Q0403</td><td>MICROWAVE ENGG.</td><td>9</td><td>14</td><td>0</td></tr></table><br><br></body></html>";
$dom->loadHTML($page);
$xp = new DOMXPath($dom);
///html/body/table/tbody/tr[td='Subject Code']/ancestor::tbody/tr
$result = $xp->query("/html/body/table/tr[td='Subject Code']/ancestor::table/tr");
$i = 2;
echo '<subs>';
while ($elm = $result->item($i)) {
    $r = $xp->query("td[1]/text()", $elm);
    echo '<sub><subcode>' . $r->item(0)->C14N() . '</subcode>';
    $r = $xp->query("td[2]/text()", $elm);
    echo '<subname>' . $r->item(0)->C14N() . '</subname></sub>';
    $i++;
}
echo '</subs>';