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
<?php

//Author: satya gowtham kudupudi
//Time: 2012-03-04 13:08:00
require 'HTTP/Request2.php';
$url = 'http://mail.ferryfair.com/PHPWebAdmin/index.php';
$r = new Http_Request2($url);
$r->setMethod(HTTP_Request2::METHOD_POST);
$r->setHeader(array("Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Charset" => "ISO-8859-1,utf-8;q=0.7,*;q=0.3", "Accept-Encoding" => "gzip,deflate,sdch", "Accept-Language" => "en-US,en;q=0.8,te;q=0.6", "Cache-Control" => "max-age=0", "Connection" => "keep-alive", "Content-Length" => "355", "Content-Type" => "application/x-www-form-urlencoded"));
$r->addPostParameter(array('page' => 'background_account_save', 'action' => 'edit', 'domainid' => '1', 'accountid' => '12', 'accountaddress' => 'capt.roja', 'accountpassword' => 'g2wjzxx1NXDeujPW', 'accountmaxsize' => '100', 'accountadminlevel' => '0', 'accountactive' => '1', 'vacationsubject' => '', 'vacationmessage' => '', 'vacationmessageexpiresdate' => '2012-03-04', 'forwardaddress' => '', 'SignaturePlainText' => '', 'SignatureHTML' => '', 'addomain' => '', 'adusername' => '', 'PersonFirstName' => '', 'PersonLastName' => ''));
$r->send();
$page = $r->getBody();
print_r($page);
 private function post_to_twitter($resp_data)
 {
     if ($this->format == 'json') {
         $data = json_decode($resp_data);
     } elseif ($this->format == 'xml') {
         $data = simplexml_load_string($resp_data);
     }
     $tweet = $this->truncate((string) $data->text) . ' ' . (string) $data->url;
     $header = $this->build_header($tweet);
     $url = "http://api.twitter.com/1/statuses/update.{$this->format}";
     $r = new Http_Request2($url, Http_Request2::METHOD_POST);
     $r->setHeader('Authorization', $header);
     $r->addPostParameter('status', $tweet);
     $res = $r->send();
     if ($res->getStatus() == 200) {
         return $this->respond($resp_data);
     } else {
         throw new TwitPicAPIException("Image uploaded, but error posting to Twitter");
     }
 }
Example #8
0
                 }
             }
             echo '<rs/>';
             ob_end_flush();
             ob_flush();
             flush();
             ob_start();
         }
         $r = new Http_Request2('https://collegedb2.ferryfair.com/lib/signOut.php');
         $r->setConfig(array("ssl_verify_peer" => FALSE, "ssl_local_cert" => "{$root}/ssl/collegedb2.ferryfair.com.cert"));
         $r->setMethod(HTTP_Request2::METHOD_POST);
         $r->addPostParameter(array('SESSION_ID' => $sessionId));
         //$r->addCookie('PHPSESSID', 'bkq0t2vf2n9898t4q83jje7bp7');
         //$r->addCookie('XDEBUG_SESSION', 'netbeans-xdebug');
         try {
             $response = $r->send();
         } catch (Exception $exc) {
             $es = $exc->getTraceAsString();
             $response = NULL;
         }
         $body = $response->getBody();
         if (strpos($body, "<status>signedOut</status>") >= 0) {
             echo json_encode(array('status' => 'I, dataGrabber.php finished my job ~:)~'));
         } else {
             echo json_encode(array('status' => 'I, dataGrabber.php unable to signOut from the ferry ~:|~'));
         }
     } else {
         echo json_encode(array('status' => 'I, dataGrabber.php unable to open the table may be i am not authorized ~:(~'));
     }
 } else {
     echo json_encode(array('status' => 'I, dataGrabber.php might got deobjectized. access denied ~:(~'));
Example #9
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;
     }
 }