コード例 #1
0
ファイル: upload_file.php プロジェクト: ZhongjunTian/Projects
        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/>";
}
コード例 #2
0
ファイル: httpReqTest.php プロジェクト: necktwi/ferry
<?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);