コード例 #1
0
ファイル: MerajDrive.php プロジェクト: jnaroogheh/darvishi
 public function sendRequest($url, $req)
 {
     $headers = array("Content-Type" => "application/xml", 'Authorization' => $this->auth);
     $url = $this->baseUrl . '/' . $url;
     $response = Unirest\Request::post($url, $headers, $req);
     //var_dump($response->body);
     //exit;
     return $response->body;
 }
コード例 #2
0
 public function post($url, $body = null)
 {
     Unirest\Request::auth($this->login, $this->pass);
     Unirest\Request::defaultHeader('User-Agent', $this->service . " (" . $this->mail . ")");
     $body = Unirest\Request\Body::json($body);
     $response = Unirest\Request::post($this->root . $url . '.json', array(), $body);
     if (floor($response->code / 100) >= 4) {
         throw new Error($response->body->errors->error[0]);
     }
     return $response->body;
 }
コード例 #3
0
function createItem()
{
    global $accessToken, $connectHost, $requestHeaders;
    $request_body = array("name" => "Milkshake", "variations" => array(array("name" => "Small", "pricing_type" => "FIXED_PRICING", "price_money" => array("currency_code" => "USD", "amount" => 400))));
    $response = Unirest\Request::post($connectHost . '/v1/me/items', $requestHeaders, json_encode($request_body));
    if ($response->code == 200) {
        error_log('Successfully created item:');
        error_log(json_encode($response->body, JSON_PRETTY_PRINT));
        return $response->body;
    } else {
        error_log('Item creation failed');
        return NULL;
    }
}
コード例 #4
0
 public function identify($params)
 {
     $headers = array("Content-Type" => "application/json", "lifecycle-api-key" => $this->lifecycle_api_key);
     $body = json_encode(array("params" => $params));
     $response = Unirest\Request::post("http://localhost:3400/v1/identify", $headers, $body);
     $response->code;
     // HTTP Status code
     $response->headers;
     // Headers
     $response->body;
     // Parsed body
     $response->raw_body;
     // Unparsed body
     return $response;
 }
コード例 #5
0
function callback()
{
    global $connectHost, $oauthRequestHeaders;
    # Extract the returned authorization code from the URL
    $authorizationCode = $_GET['code'];
    if ($authorizationCode) {
        # Provide the code in a request to the Obtain Token endpoint
        $oauthRequestBody = array('client_id' => $applicationId, 'client_secret' => $applicationSecret, 'code' => $authorizationCode);
        $response = Unirest\Request::post($connectHost . '/oauth2/token', $oauthRequestBody, $requestHeaders);
        # Extract the returned access token from the response body
        if (property_exists($response, 'access_token')) {
            # Here, instead of printing the access token, your application server should store it securely
            # and use it in subsequent requests to the Connect API on behalf of the merchant.
            error_log('Access token: ' . $response->access_token);
            error_log('Authorization succeeded!');
            # The response from the Obtain Token endpoint did not include an access token. Something went wrong.
        } else {
            error_log('Code exchange failed!');
        }
        # The request to the Redirect URL did not include an authorization code. Something went wrong.
    } else {
        error_log('Authorization failed!');
    }
}
コード例 #6
0
 public function testUploadIfFilePartOfData()
 {
     $response = Unirest\Request::post('http://mockbin.com/request', array('Accept' => 'application/json'), array('name' => 'Mark', 'files[owl.gif]' => Unirest\File::add(UPLOAD_FIXTURE)));
     $this->assertEquals(200, $response->code);
     $this->assertEquals('POST', $response->body->method);
     $this->assertEquals('Mark', $response->body->postData->params->name);
     $this->assertEquals('This is a test', $response->body->postData->params->{'files[owl.gif]'});
 }
コード例 #7
0
ファイル: Dfcapi.php プロジェクト: dfcplc/dfcapi-php
 /**
  * Cancel Direct Debits
  *
  * @param string $api_key DFC API Key
  * @param string $api_secret DFC API Secret
  * @param string $dfc_ref DFC Customer Reference
  * @param string $apply_from
  *
  * @return boolean API Cancel Status (true/false)
  */
 public function CancelDirectDebit($api_key, $api_secret, $dfc_ref, $apply_from)
 {
     $data['authentication'] = array('apikey' => $api_key, 'apisecret' => $api_secret, 'dfc_ref' => $dfc_ref);
     $data['cancel'] = array('apply_from' => $apply_from);
     $this->clearStoredResponse();
     $response = Unirest\Request::post($this->api_url_cancel_directdebit, ["Content-Type" => "application/json", "Accept" => "application/json"], json_encode($data));
     $this->setStoredResponse($response);
     if (isset($response->code) && $response->code === 200 && isset($response->body->status) && $response->body->status === 'ok') {
         return true;
     }
     return false;
 }
コード例 #8
0
ファイル: RequestTest.php プロジェクト: pombredanne/ArcherSys
    public function testUploadIfFilePartOfData()
    {
        $response = Unirest\Request::post('http://httpbin.org/post', array(
            'Accept' => 'application/json'
        ), array(
            'name' => 'Mark',
            'files[owl.gif]' => Unirest\File::add(UPLOAD_FIXTURE)
        ));
        $this->assertEquals(200, $response->code);

        //$files = $response->body->files;
        //$this->assertEquals('This is a test', $files->file);

        $form = $response->body->form;
        $this->assertEquals('Mark', $form->name);
    }
コード例 #9
0
 public function acceptOffer($options)
 {
     if (!$options['tradeOfferId']) {
         die('No options');
     }
     $form = array('sessionid' => $this->sessionId, 'serverid' => 1, 'tradeofferid' => $options['tradeOfferId']);
     $referer = 'https://steamcommunity.com/tradeoffer/' . $options['tradeOfferId'] . '/';
     $headers = array('Cookie' => $this->webCookies, 'Timeout' => Unirest\Request::timeout(5));
     $headers['referer'] = $referer;
     $response = Unirest\Request::post('https://steamcommunity.com/tradeoffer/' . $options['tradeOfferId'] . '/accept', $headers, $form);
     if ($response->code != 200) {
         die('Error accepting offer. Server response code: ' . $response->code);
     }
     $body = $response->body;
     if ($body && $body->strError) {
         die('Error accepting offer: ' . $body->strError);
     }
     return $body;
 }
コード例 #10
0
 /**
  * Execute POST request to Seats.io RESTful API
  * Full response in $this->response
  * @see Unirest for PHP http://unirest.io/php.html
  *
  * @param string 	$url endpoint URL
  * @return mixed 	Data - body of response
  *
  * @throws exceptionclass Throws exception when HTTP response is not 200
  *
  * @access private
  */
 private function postRequest($url = null)
 {
     if (!empty($url)) {
         $this->request->url = $url;
     }
     $this->response = Unirest\Request::post($this->request->url, $this->request->headers, json_encode($this->request->data));
     if ($this->response->code !== 200) {
         throw new Exception('postRequest - Exception: ' . (!empty($this->response->body) ? $this->response->body->message : $this->response->headers[0]));
     }
     return $this->response->body;
 }
コード例 #11
0
ファイル: signup.php プロジェクト: rimaraksa/Approve_Server
 $profpic = $_POST['profpic'];
 $signature = $_POST['signature'];
 $account = array();
 // Getting server ip address
 $serverIP = gethostbyname(gethostname());
 // Getting target folder of the signature
 $targetPath = "signatures/";
 // Final file url that is being uploaded
 $fileUpload = '/Users/rimaraksa/Sites/android_connect' . '/' . $targetPath . $signature;
 // Change X-Mashape-Key, album, and album key
 $X_Mashape_Key = "yxgaLRvhf3msh8lKOCP4kiyng64Np1NlssnjsngXI6UmUTXXBN";
 $album = "Approve";
 $albumkey = "93047593e2f2fb8176be64548e998490f3ee24ec4ce7d091d7082eea18051c5d";
 $url = "https://lambda-face-recognition.p.mashape.com/album_train";
 // Train the album in Lambdal server
 $response = Unirest\Request::post($url, array("X-Mashape-Key" => $X_Mashape_Key), array("album" => $album, "albumkey" => $albumkey, "entryid" => $username, "files" => Unirest\File::add($fileUpload)));
 // Write the respose after training the album
 $file = fopen("log_album_train.txt", "w");
 fwrite($file, $response->raw_body);
 fclose($file);
 // URL for rebuilding an album
 $url = "https://lambda-face-recognition.p.mashape.com/album_rebuild?album=" . $album . "&albumkey=" . $albumkey;
 // Rebuild the album in Lambdal server
 $response = Unirest\Request::get($url, array("X-Mashape-Key" => $X_Mashape_Key, "Accept" => "application/json"));
 // Write the respose from rebuilding the album
 $file = fopen("log_album_rebuild.txt", "w");
 fwrite($file, $response->raw_body);
 fclose($file);
 // Prepare for returning the result to user
 // The file was not uploaded successfully to Lambal server
 if (!$response) {
コード例 #12
0
ファイル: site.php プロジェクト: akosgarai/datamine
 private function doSkyttleAnalyzation($text, $options)
 {
     $url = "https://sentinelprojects-skyttle20.p.mashape.com/";
     $mashape_key = "xyumIBzeMJmshIB41rhsw7ALq5btp1QopRZjsnfDjm4RnA4pDR";
     $headers = array("X-Mashape-Key" => $mashape_key, "Content-Type" => "application/x-www-form-urlencoded", "Accept" => "application/json");
     $body = array("annotate" => 0, "keywords" => 1, "lang" => "en", "sentiment" => 1, "text" => $text);
     if ($options != '') {
         $body['domain'] = $options;
     }
     // Mashape auth
     Unirest\Request::setMashapeKey($mashape_key);
     $response = Unirest\Request::post($url, $header, $body);
     if ($response->code == "200") {
         //return json_encode(array('status'=>'OK', 'site'=>'doSkyttleAnalyzation_200_OK'));
         return $response->body;
     } else {
         return array('responseCode' => $response->code);
     }
 }
コード例 #13
0
ファイル: index.php プロジェクト: messaar/imei
<?php

require_once 'vendor/autoload.php';
$imei = intval("3557410674329634");
// These code snippets use an open-source library. http://unirest.io/php
$response = Unirest\Request::post("https://ismaelc-imei-info.p.mashape.com/checkimei?login=Ammly&password=sub00ts]0M", array("X-Mashape-Key" => "HINimqmaqjmshU3SF2tlVyJo79mwp1LPmtTjsniTICNVxdvAYq", "Content-Type" => "application/x-www-form-urlencoded", "Accept" => "application/json"), array("imei" => "357791062734465"));
echo "<pre>";
print_r($response);
コード例 #14
0
ファイル: untest.php プロジェクト: jnaroogheh/darvishi
  <Source AirlineVendorID="JI" ISOCountry="IR" ISOCurrency="IRR">
                                  <RequestorID Type="5" ID="DARVISHI"/>
  </Source>
 </POS>
                  <OriginDestinationInformation>
                          <DepartureDateTime>2016-02-04</DepartureDateTime>
                          <OriginLocation LocationCode="MHD"/>
                          <DestinationLocation LocationCode="THR"/>
                  </OriginDestinationInformation>

               <TravelPreferences >
                  <CabinPref  Cabin="Economy"/>
               </TravelPreferences>

                  <TravelerInfoSummary>
                          <AirTravelerAvail>				
                                  <PassengerTypeQuantity Code="ADT" Quantity="1"/>			
                          </AirTravelerAvail>
                  </TravelerInfoSummary>
                  <ProcessingInfo SearchType="STANDARD"/>
          </OTA_AirLowFareSearchRQ>';
$response = Unirest\Request::post("http://booking.merajairlines.ir:8180/wsbe/rest/availability/lowfaresearch", $headers, $body);
var_dump($response->body);
$response->code;
// HTTP Status code
$response->headers;
// Headers
$response->body;
// Parsed body
$response->raw_body;
// Unparsed body
コード例 #15
0
ファイル: convert.php プロジェクト: biwax/OVOMA
<?php

require_once 'unirest/Unirest.php';
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
// download all pdfs to a location
// (use common code from the aggregator)
// convert each PDF to an image
// These code snippets use an open-source library.
/*$response = Unirest\Request::post("https://pdf2jpg-pdf2jpg.p.mashape.com/convert_pdf_to_jpg.php",
  array(
    "X-Mashape-Key" => "4vQThd6WoJmshrauqDPfPu1tlWvvp1g826MjsnxIB4i4LNPhaf"
  ),
  array(
    "pdf" => Unirest\file::add(getcwd() . "/boc.pdf"),
    "resolution" => 150
  )
);*/
$response = Unirest\Request::post("http://mockbin.org/bin/800a818b-5fb6-40d4-a342-75a1fb8599db?foo=bar&foo=baz", array("X-Mashape-Key" => "4vQThd6WoJmshrauqDPfPu1tlWvvp1g826MjsnxIB4i4LNPhaf"), array("pdf" => Unirest\Request::get("http://www.le-pinocchio.ch/view/data/3070/Menu%20de%20la%20semaine%202015.pdf"), "resolution" => 150));
if ($response->code == 200) {
    echo $response->body[0]->color;
} else {
    echo 'error while converting';
}