Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 3
0
 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;
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 5
0
	<?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;
}
Ejemplo n.º 6
0
<?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;
}
Ejemplo n.º 7
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);
<?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;
}
Ejemplo n.º 9
0
 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");
     }
 }
Ejemplo n.º 10
0
 } else {
     $sourcePath = $_FILES['file']['tmp_name'];
     // Storing source path of the file in a variable
     $targetPath = "upload/" . $_FILES['file']['name'];
     // Target path where file is to be stored
     move_uploaded_file($sourcePath, $targetPath);
     // Moving Uploaded file
     echo "<br/><b>File Name:</b> " . $_FILES["file"]["name"] . "<br>";
     echo "<b>Type:</b> " . $_FILES["file"]["type"] . "<br>";
     echo "<b>Size:</b> " . $_FILES["file"]["size"] / 1024 . " kB<br>";
     echo "<b>Temp file:</b> " . $_FILES["file"]["tmp_name"] . "<br>";
     //start of emotion api
     echo "<br/><span id='success'>Facial Emotioin Detect Successfully...!!</span><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/>";
Ejemplo n.º 11
0
         if ($fetchErrCount > 10) {
             echo '<rs/>';
             ob_end_flush();
             ob_flush();
             flush();
             ob_start();
             break;
         }
     }
     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 {
/*

Read about the spell check API: https://www.projectoxford.ai/spellcheck

The free offer provides access to the Spell Check APIs to detect and recognize a range of spelling errors. With this free plan, calling to the Spell Check APIs is limited to 7 transactions per minute and 5,000 transactions per month.
*/
define('POXFORD_SPELLCHECK_KEY', 'your-api-key');
// 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,
Ejemplo n.º 13
0
<?php

require 'HTTP/Request2.php';
$url = 'https://collegedb2.ferryfair.com/lib/crap.html';
$r = new Http_Request2($url);
$r->setConfig(array("ssl_verify_peer" => FALSE, "ssl_local_cert" => "{$root}/ssl/collegedb2.ferryfair.com.cert"));
/* $r->setHeader(array(
  "Content-Type" => "application/x-www-form-urlencoded"
  ));
  $r->addPostParameter(array(
  'username' => $usrname,
  'ePass' => $ePass,
  'fullName' => $_POST['fullName']
  )); */
//$r->addCookie('PHPSESSID', 'bkq0t2vf2n9898t4q83jje7bp7');
//$r->addCookie('XDEBUG_SESSION', 'netbeans-xdebug');
try {
    $response = $r->send();
} catch (Exception $exc) {
    $es = $exc->getTraceAsString();
    $ets = $exc->__toString();
    $egc = $exc->getCode();
    $egl = $exc->getLine();
    $egm = $exc->getMessage();
    $egt = $exc->getTrace();
    $response = null;
    echo $es . $ets . $egc . $egl . $egm . $egt . $response;
}
$page = $response->getBody();
echo $page;
Ejemplo n.º 14
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;
     }
 }
Ejemplo n.º 15
0
 $us = TRUE;
 $query = "UPDATE users SET users.PID=" . $lastPIndex . " WHERE users.index=" . $lastUIndex;
 $result = mysql_query($query, $dbc);
 $error3 = mysql_error($dbc);
 if (!$error3) {
     $mkdir = mkdir('../../userFiles/' . $usrname);
     $fhandler = fopen('../../userFiles/' . $usrname . '/live.shm', 'w');
     fclose($fhandler);
     $photo_id = $_POST['photoID'];
     if (copy('../../tmp/' . $photo_id, '../../userFiles/' . $usrname . '/' . $photo_id)) {
         unlink('../../tmp/' . $photo_id);
     }
     // Connect to hMailServer
     require 'HTTP/Request2.php';
     $url = 'http://mail.ferryfair.com/PHPWebAdmin/standardAccountCreator.php';
     $r = new Http_Request2($url);
     $r->setMethod(HTTP_Request2::METHOD_POST);
     $r->setHeader(array("Content-Type" => "application/x-www-form-urlencoded"));
     $r->addPostParameter(array('username' => $usrname, 'ePass' => $ePass, 'fullName' => $_POST['fullName']));
     $r->addCookie('PHPSESSID', 'bkq0t2vf2n9898t4q83jje7bp7');
     $r->addCookie('XDEBUG_SESSION', 'netbeans-xdebug');
     $response = $r->send();
     $page = $response->getBody();
     $dd = new DOMDocument();
     $dd->loadXML($page);
     $st = innerHTML($dd->getElementsByTagName('status')->item(0));
     $accountId = innerHTML($dd->getElementsByTagName('accountId')->item(0));
     if ($mkdir && $accountId) {
         $key = ftok('../../userFiles/' . $usrname . '/live.shm', 'c');
         $shmId = shm_attach($key);
         $user['status'] = 0;
Ejemplo n.º 16
0
if ($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/pjpeg") {
    if ($_FILES["file"]["error"] > 0) {
        echo "Error: " . $_FILES["file"]["error"] . "<br />";
    } else {
        echo "Upload: " . $_FILES["file"]["name"] . "<br />";
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        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/>";
Ejemplo n.º 17
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>';