get() public static method

Send a GET request to a URL
public static get ( string $url, array $headers = [], mixed $parameters = null, string $username = null, string $password = null ) : unirest\Response
$url string URL to send the GET request to
$headers array additional headers to send
$parameters mixed parameters to send in the querystring
$username string Authentication username (deprecated)
$password string Authentication password (deprecated)
return unirest\Response
コード例 #1
2
 /**
  * @param string|array $param Options or ID
  * @return \stdClass
  */
 public function fetch($param)
 {
     if (is_string($param)) {
         return new Payment($this->response(Request::get(Endpoints::fetch($param))->raw_body));
     } else {
         $response = json_decode(Request::get(Endpoints::fetch($param))->raw_body, true);
         $json['entity'] = "collection";
         foreach ($response as $key => $item) {
             $json['items'][$key] = new Payment($this->response($item));
         }
         return $this->response($json);
     }
 }
コード例 #2
0
 public function getSubdistrict($city_id, $subdistrict_id = NULL)
 {
     $params = is_null($city_id) ? NULL : array('city' => $city_id);
     if (!is_null($subdistrict_id)) {
         $params['id'] = $subdistrict_id;
     }
     return \Unirest\Request::get($this->getEndPoint() . "subdistrict", $this->getHeader(), $params)->body->rajaongkir->results;
 }
コード例 #3
0
ファイル: Ossbss.php プロジェクト: cloudapidev/apibay
 public function getInfo($url, $inputs = null, $param = null)
 {
     $url = setApiUrl($url, $param);
     //Log::info($url."\n");
     $response = Unirest\Request::get($url, $this->_headers, $inputs);
     //Log::info(json_encode($response)."\n");
     return dealResponse($response);
 }
コード例 #4
0
ファイル: Video.php プロジェクト: baiy/video_parse
 /**
  * 获取播放地址
  * @return array
  */
 public function getPlayUrl()
 {
     $response = \Unirest\Request::get($this->url);
     preg_match('#value=\'(?<url>.*?)\'><a id="v_slink_souce"#', $response->body, $m);
     if (!empty($m['url'])) {
         return ['swf' => trim($m['url'])];
     }
     return false;
 }
コード例 #5
0
ファイル: Video.php プロジェクト: baiy/video_parse
 /**
  * 获取播放地址
  * @return array
  */
 public function getPlayUrl()
 {
     $play_url = 'http://share.vrs.sohu.com/my/v.swf&topBar=1&id={id}&autoplay=false&from=page';
     $response = \Unirest\Request::get($this->url);
     preg_match("#vid: '(?<id>.*?)',#", $response->body, $m);
     if (!empty($m['id'])) {
         return ['swf' => str_replace('{id}', $m['id'], $play_url)];
     }
     return false;
 }
コード例 #6
0
ファイル: daemon.php プロジェクト: PhenixH/PufferPanel
 /**
  * Checks if the daemon is running.
  *
  * @param string $ip
  * @param int $port
  * @param int $timeout
  * @return bool
  */
 public function avaliable($ip, $port = 5656, $timeout = 3)
 {
     Unirest\Request::timeout($timeout);
     try {
         Unirest\Request::get("https://" . $ip . ":" . $port);
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #7
0
 /**
  * Get list of searched contact list
  * @param  string     $q     Required parameter: Your keyword or query.
  * @return string response from the API call*/
 public function searchContactList($q)
 {
     //check that all required arguments are provided
     if (!isset($q)) {
         throw new \InvalidArgumentException("One or more required arguments were NULL.");
     }
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/search/contacts-lists';
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('q' => $q));
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'ClickSendSDK');
     //set HTTP basic auth parameters
     Request::auth(Configuration::$username, Configuration::$key);
     //and invoke the API call request to fetch the response
     $response = Request::get($_queryUrl, $_headers);
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('BAD_REQUEST', 400, $response->body);
     } else {
         if ($response->code == 401) {
             throw new APIException('UNAUTHORIZED', 401, $response->body);
         } else {
             if ($response->code == 403) {
                 throw new APIException('FORBIDDEN', 403, $response->body);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('NOT_FOUND', 404, $response->body);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('METHOD_NOT_FOUND', 405, $response->body);
                     } else {
                         if ($response->code == 429) {
                             throw new APIException('TOO_MANY_REQUESTS', 429, $response->body);
                         } else {
                             if ($response->code == 500) {
                                 throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body);
                             } else {
                                 if ($response->code < 200 || $response->code > 206) {
                                     //[200,206] = HTTP OK
                                     throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $response->body;
 }
コード例 #8
0
 /**
  * A Config object has the following attributes:+ `timezone` - Our sever timezone+ `now` - Our server timestamp+ `version` - Current version is "1.0"+ `serverUrl` - Main API URL+ `photosUrl` - Base Path to server where we store our images+ `productsSorting` - Available Products lists sorting options (can be combined with commas, for example &sort=date,-price )    + `date` - Date ascending    + `-date` - Date descending    + `price` - Price ascending    + `-price` - Price descending    + `distance` - Distance ascending (works only if `latitude`,`longitude` & `distance` parameters are provided, ignored otherwise)     + `-distance` - Distance descending (works only if `latitude`,`longitude` & `distance` parameters are provided, ignored otherwise)+ user - All important userdata for provided API key    + `name` - Name / Company / Organization    + `email` - E-Mail Address    + `uuid` - Unique ID    + `continueUrl` - Continue URL (not in use now)    + `notifyUrl` - Notify URL (not in use now)    + `suggestedMarkup` - Suggested markup, % decimal value, for example 7.5    + `defaultPagination` - Default Pagination value (per page), between 1-100    + `defaultSortBy` - Default sort by for /products (if not specified)    + `defaultCurrencyUuid` - Default currency UUID for /products (if not specified)    + `defaultCurrencyCode` - Default currency code for /products (if not specified)    + `defaultLanguageUuid` - Default language UUID  /products (if not specified)    + `defaultLanguageCode` - Default language code  /products (if not specified)    + `walletBalance` - Partner's available wallet balance, based on his deposits    + `walletAvailableBalance` - Wallet balance which is a combination of partner's deposit and assigned credit amount    + `wallet_alert_value` - Threshold value in SGD, when `walletBallance` reach this value then BMG and partner will be notified on this event+ `languages` - A list of supported languages.+ `currencies` - An array of supported currencies.+ `types` - An array of supported products types.+ `categories` - A tree of supported product categories.+ `locations` - A tree of supported locations. (Continent -> Country -> State -> City)
  * @return mixed response from the API call
  * @throws APIException Thrown if API call fails
  */
 public function retrieveConfig()
 {
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/v1/config';
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'BeMyGuest.SDK.v1', 'Accept' => 'application/json', 'X-Authorization' => Configuration::$xAuthorization);
     //call on-before Http callback
     $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl);
     if ($this->getHttpCallBack() != null) {
         $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest);
     }
     //and invoke the API call request to fetch the response
     $response = Request::get($_queryUrl, $_headers);
     //call on-after Http callback
     if ($this->getHttpCallBack() != null) {
         $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body);
         $_httpContext = new HttpContext($_httpRequest, $_httpResponse);
         $this->getHttpCallBack()->callOnAfterRequest($_httpContext);
     }
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('Wrong Arguments', $_httpContext);
     } else {
         if ($response->code == 401) {
             throw new APIException('Unauthorized', $_httpContext);
         } else {
             if ($response->code == 403) {
                 throw new APIException('Forbidden', $_httpContext);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('Resource Not Found', $_httpContext);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('Method Not Allowed', $_httpContext);
                     } else {
                         if ($response->code == 410) {
                             throw new APIException('Resource No Longer Available', $_httpContext);
                         } else {
                             if ($response->code < 200 || $response->code > 208) {
                                 //[200,208] = HTTP OK
                                 throw new APIException("HTTP Response Not OK", $_httpContext);
                             }
                         }
                     }
                 }
             }
         }
     }
     $mapper = $this->getJsonMapper();
     return $mapper->map($response->body, new Models\RetrieveConfigResponse());
 }
コード例 #9
0
ファイル: Video.php プロジェクト: baiy/video_parse
 /**
  * 获取播放地址
  * @return array
  */
 public function getPlayUrl()
 {
     $play_url = 'http://www.tudou.com/a/{lcode}/&iid={iid}&resourceId=0_04_05_99/v.swf';
     $response = \Unirest\Request::get($this->url);
     preg_match('#,lcode: \'(?<lcode>.*?)\'#', $response->body, $l);
     preg_match('#,iid: (?<iid>[0-9]+)#', $response->body, $i);
     if (!empty($l['lcode'])) {
         return ['swf' => str_replace(['{lcode}', '{iid}'], [$l['lcode'], $i['iid']], $play_url)];
     }
     return false;
 }
コード例 #10
0
ファイル: Video.php プロジェクト: baiy/video_parse
 /**
  * 获取播放地址
  * @return array
  */
 public function getPlayUrl()
 {
     $play_url = 'http://player.video.qiyi.com/{vid}/0/0/v_{uid}.swf-albumId=-tvId={id}-isPurchase=0-cnId=';
     $response = \Unirest\Request::get($this->url);
     preg_match('#data-player-videoid="(?<vid>.*?)"#', $response->body, $v);
     preg_match('#data-player-tvid="(?<id>.*?)"#', $response->body, $m);
     preg_match('#v_(?<uid>.*?)\\.html#', $this->url, $u);
     if (!empty($m['id'])) {
         return ['swf' => str_replace(['{id}', '{vid}', '{uid}'], [$m['id'], $v['vid'], $u['uid']], $play_url)];
     }
     return false;
 }
コード例 #11
0
 /**
  * Get all referral accounts
  * @return string response from the API call*/
 public function getReferralAccounts()
 {
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/referral/accounts';
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'ClickSendSDK');
     //set HTTP basic auth parameters
     Request::auth(Configuration::$username, Configuration::$key);
     //and invoke the API call request to fetch the response
     $response = Request::get($_queryUrl, $_headers);
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('BAD_REQUEST', 400, $response->body);
     } else {
         if ($response->code == 401) {
             throw new APIException('UNAUTHORIZED', 401, $response->body);
         } else {
             if ($response->code == 403) {
                 throw new APIException('FORBIDDEN', 403, $response->body);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('NOT_FOUND', 404, $response->body);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('METHOD_NOT_FOUND', 405, $response->body);
                     } else {
                         if ($response->code == 429) {
                             throw new APIException('TOO_MANY_REQUESTS', 429, $response->body);
                         } else {
                             if ($response->code == 500) {
                                 throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body);
                             } else {
                                 if ($response->code < 200 || $response->code > 206) {
                                     //[200,206] = HTTP OK
                                     throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $response->body;
 }
コード例 #12
0
ファイル: Video.php プロジェクト: baiy/video_parse
 /**
  * 获取播放地址
  * @return array
  */
 public function getPlayUrl()
 {
     if (strpos($this->url, 'my.')) {
         $play_url = 'http://share.vrs.sohu.com/my/v.swf&topBar=1&id={id}&autoplay=false';
         preg_match("#(?<id>[0-9]+).sh#", $this->url, $m);
         if (!empty($m['id'])) {
             return ['swf' => str_replace('{id}', $m['id'], $play_url)];
         }
     } else {
         $play_url = 'http://share.vrs.sohu.com/{id}/v.swf&autoplay=false';
         $response = \Unirest\Request::get($this->url);
         preg_match('#vid="(?<id>.*?)"#', $response->body, $m);
         if (!empty($m['id'])) {
             return ['swf' => str_replace('{id}', $m['id'], $play_url)];
         }
     }
     return false;
 }
コード例 #13
0
 public function dic()
 {
     $data = Request::capture();
     // https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
     $response = \Unirest\Request::get("https://glosbe.com/gapi/translate", null, array('from' => 'eng', 'dest' => 'eng', 'format' => 'json', 'phrase' => $data['word'], 'pretty' => 'false', 'tm' => 'true'));
     $ms = json_decode($response->raw_body);
     // dd($ms);
     // Get Examples in $ms->examples. English in $ms->examples->first, Other Language in $ms->examples->second
     $examples = array();
     // Get English Meaning in $ms->meanings, other language in $ms->phrase
     $meanings = array();
     if (count($ms->examples) > 0) {
         $i = 0;
         foreach ($ms->examples as $key => $value) {
             if (isset($value->first)) {
                 $examples += array($key => $value->first);
             }
             $i++;
             if ($i >= 5) {
                 break;
             }
         }
     }
     // dd($examples);
     if (isset($ms->tuc)) {
         if (count($ms->tuc) > 0) {
             $ms = json_decode($response->raw_body)->tuc[0]->meanings;
         }
         // dd($ms[0]->text);
         // dd($ms);
         $i = 0;
         foreach ($ms as $key => $value) {
             $meanings += array($key => $value->text);
             $i++;
             if ($i >= 5) {
                 break;
             }
         }
     }
     // dd($meanings);
     echo json_encode(['meanings' => $meanings, 'examples' => $examples]);
     // dd(['examples' => $examples, 'meanings' => $meanings]);
 }
コード例 #14
0
ファイル: Flvcd.php プロジェクト: baiy/video_parse
 /**
  * 解析下载地址
  *
  * @param  string $url 页面地址
  *
  * @return array
  */
 public function parse($url)
 {
     $flvcd_url = 'http://www.flvcd.com/parse.php?kw=' . urlencode($url);
     $response = \Unirest\Request::get($flvcd_url);
     $html = iconv('GB2312', 'UTF-8//IGNORE', $response->body);
     // 下载地址
     preg_match_all('#href="(?<url>.*?)".*?onclick=\'_alert\\(\\);return false;\'#', $html, $m);
     $down_list = [];
     if (!empty($m['url'])) {
         foreach ($m['url'] as $key => $value) {
             $down_list[] = trim($value);
         }
     }
     // 名称
     preg_match('#document.title = "(?<title>.*?)" \\+#', $html, $m);
     $title = empty($m['title']) ? '' : trim($m['title']);
     if (empty($down_list) || empty($title)) {
         return [];
     }
     return ['title' => $title, 'down_list' => $down_list];
 }
コード例 #15
0
ファイル: AbstractApi.php プロジェクト: ignittion/kong-php
 /**
  * The underlying call to the Kong Server
  *
  * @throws \Ignittion\Kong\KongException when something goes wrong with the Http request
  *
  * @param string $verb
  * @param string $uri
  * @param array $options
  * @param array $body
  * @return \stdClass
  */
 public function call($verb, $uri, array $params = [], array $body = [], array $headers = [])
 {
     $verb = strtoupper($verb);
     $api = "{$this->url}:{$this->port}/{$uri}";
     $headers = array_merge($headers, ['Content-Type: application/json']);
     try {
         switch ($verb) {
             case 'GET':
                 $request = RestClient::get($api, $headers, $params);
                 break;
             case 'POST':
                 $request = RestClient::post($api, $headers, $body);
                 break;
             case 'PUT':
                 $request = RestClient::put($api, $headers, $body);
                 break;
             case 'PATCH':
                 $request = RestClient::patch($api, $headers, $body);
                 break;
             case 'DELETE':
                 $request = RestClient::delete($api, $headers);
                 break;
             default:
                 throw new Exception('Unknown HTTP Request method.');
         }
     } catch (Exception $e) {
         throw new KongException($e->getMessage());
     }
     // save this request
     $this->body = $request->body;
     $this->headers = $request->headers;
     $this->httpCode = $request->code;
     $this->rawBody = $request->raw_body;
     // return a more simplified response
     $object = new stdClass();
     $object->code = $this->httpCode;
     $object->data = $this->body;
     return $object;
 }
コード例 #16
0
 /**
  * Send the request
  *
  * @return GenderizeResponse
  */
 public function get()
 {
     $headers = array('Accept' => 'application/json');
     $response = $this->request->get(self::API_URL, $headers, $this->buildQuery());
     return new GenderizeResponse($response);
 }
コード例 #17
0
 /**
  * ###ResponseA response object has the following attributes:  + `uuid` - UUID of product+ `published` - true / false,+ `title` - Title of product. Always on English+ `titleTranslated` - Title of product on requested language+ `description` - Description of product. Always on English+ `descriptionTranslated` - Description of product on requested language+ `highlights` - Highlights of product. Always on English+ `highlightsTranslated` - Highlights of product on requested language+ `additionalInfo` - Additional information of product. Always on English+ `additionalInfoTranslated` - Additional information of product on requested language+ `priceIncludes` - What's included in product price+ `priceIncludesTranslated` - Translated version of `priceIncludes`+ `itinerary` - Activity itinerary - only applicable for Package type, will be `NULL` for others+ `itineraryTranslated` - translated version of itinerary+ `warnings` - Warnings of the activity (related to safety and insurance)+ `warningsTranslated` - translated version of warnings+ `safety` - activity safety information+ `safetyTranslated` - translated version of safety information+ `latitude` - Latitude+ `longitude` - Longitude+ `minPax` - Minimum number of pax+ `maxPax` - Maximum number of pax+ `basePrice` - Base price of product (for list only)+ `currency` - Currency+ `isFlatPaxPrice` - `true/false` (An indication to tell if the `Product` has the same price for each pax in all of its `productTypes` for the selected date. )+ `reviewCount` - Number of reviews+ `reviewAverageScore` - Average score+ `typeName` - Type of product+ `typeUuid` - Type UUID+ `businessHoursFrom` - supplier business hours `from`+ `businessHoursTo` - supplier business hours `to`+ `meetingTime` - meeting time+ `hotelPickup` - `true/false` + `meetingLocation` - instructions about meeting location with supplier+ `meetingLocationTranslated` - translated version of meeting location+ `photosUrl` - Base URL for images+ `photos` - Array of photos in different dimensions (Sizes: original, 75x50, 175x112, 680x325)+ `categories` - Array of categories+ `locations` - Information about product location+ `url` - URL of product If you requested only unpublished (`published` = `false`) products then the list will be simplified.Each element will consist only of these attributes:        {          "data": [            {                "uuid":"b03ce312-742f-5256-bfe2-014daf1c8d01",                "published":false,                "title":"Everest BaseCamp Trek - 16 Days",                "titleTranslated":null            },            {                "uuid":"d70fb77c-3e97-591e-b876-d638a643c41b",                "published":false,                "title":"Half day rock climbing, Ha Long Bay, Vietnam",                "titleTranslated":null            }            [...]        }If you requested only deleted (`deleted` = `false`) products then the list will be simplified.In this case `published` parameter will be ignored.This parameter exists to help partners to synchronize its cached products database.Each element will consist only of these attributes:        {          "data": [            {                "uuid":"b03ce312-742f-5256-bfe2-014daf1c8d01",                "deletedAt":"2015-06-01 14:28:37",                "title":"Everest BaseCamp Trek - 16 Days",                "titleTranslated":null            },            {                "uuid":"d70fb77c-3e97-591e-b876-d638a643c41b",                "published":"deletedAt":"2015-06-01 14:28:37",                "title":"Half day rock climbing, Ha Long Bay, Vietnam",                "titleTranslated":null            }            [...]        }###RequestA request can take these parameters:+ `type`: `b90bd912-3e92-52e6-8abb-c2722cf947db` (optional, string) - UUID of type of product+ `country`: `ebbfac98-5f89-5106-9c4e-9e5dfd485231` (optional, string) - UUID of country+ `city`: `f67e3919-036d-11e5-a2a9-d07e352b4840` (optional, string) - UUID of city - it will always overwrite (nullify) country parameter if provided+ `price_min`: 25.00 (optional, decimal) - minimal price in decimal format 000.00 - it's compared to base price+ `price_max`: 100.00 (optional, decimal) - max price in decimal format 000.00+ `category`: `5a6495b5-9a58-5257-93db-902ca3cf8b40` (optional, string) - UUID of litsing category+ `pax`: `2` (optional, integer) - number of guests+ `currency`: `79efbd4e-3648-5204-8f35-a0e51661a4c7` (optional, string) - currency UUID, also currency code may be provided in exchange+ `language`: `ZH-HANS` (optional, string) - language UUID, also language code may be provided+ `date_start`: `2015-06-25` (optional, string) - product start date, format YYYY-MM-DD+ `date_end`: `2015-06-30` (optional, string) - product end date, format YYYY-MM-DD+ `query`: `diving in Bali` (optional, string) - free phrase for text search for example &query=Bali+ `duration_days_min`: `0` (optional,integer) - product duration minimum days (default 0)+ `duration_days_max`: `0` (optional,integer) - product duration maximum days (default NULL)+ `latitude`: `1.313430` (optional, float) - search in distance radius: latitude value + `longitude`: `103.883768` (optional, float) - search in distance radius: longitude value+ `distance`: `10.5` (optional, float) - search in distance radius in km - to use this param you need to provide always 3 parameters: latitude, longitude and distance+ `sort`: `price` (optional, string) - sorting field, example: &sort=date,-price  or &sort=price+ `page`: `5` (optional, integer) - page number for results+ `per_page`: `25` (optional, integer) - how many results per page - if not provided default value from user account will be used+ `published`: `true` (optional, string) - default is set to true, if set to false then a list of shortened unpublished products will be returned+ `deleted`: `false` (optional, string) - default is set to false, if set to true then a list of shortened deleted products will be returned
  * @param  string      $category              Optional parameter: UUID of litsing category
  * @param  string      $city                  Optional parameter: UUID of city, it will always overwrite country parameter if provided
  * @param  string      $country               Optional parameter: UUID of country
  * @param  string      $currency              Optional parameter: currency UUID, also currency code may be provided in exchange
  * @param  string      $dateEnd               Optional parameter: product end date, format YYYY-MM-DD
  * @param  string      $dateStart             Optional parameter: product start date, format YYYY-MM-DD
  * @param  string      $deleted               Optional parameter: default is set to `false`
  * @param  string      $distance              Optional parameter: Distance in km
  * @param  integer     $durationDaysMax       Optional parameter: product duration maximum days (default NULL)
  * @param  integer     $durationDaysMin       Optional parameter: product duration minimum days (default 0)
  * @param  string      $language              Optional parameter: language UUID, also language code may be provided. It will overwrite the default language from user account
  * @param  string      $latitude              Optional parameter: Latitude value
  * @param  string      $longitude             Optional parameter: Longitute value
  * @param  double      $page                  Optional parameter: page number for results
  * @param  double      $pax                   Optional parameter: number of people
  * @param  double      $perPage               Optional parameter: how many results per page - if not provided default value from user account will be used
  * @param  integer     $priceMax              Optional parameter: max price in decimal format 000.00
  * @param  integer     $priceMin              Optional parameter: minimal price in decimal format 000.00 - it's compared to base price
  * @param  string      $published             Optional parameter: default is always set to `true`
  * @param  string      $query                 Optional parameter: free phrase for text search for example &query=Bali
  * @param  string      $sort                  Optional parameter: sorting field, example: &sort=date,-price  or &sort=price
  * @param  string      $type                  Optional parameter: UUID of type of product
  * @return mixed response from the API call
  * @throws APIException Thrown if API call fails
  */
 public function getProductsList($category = NULL, $city = NULL, $country = NULL, $currency = NULL, $dateEnd = NULL, $dateStart = NULL, $deleted = NULL, $distance = NULL, $durationDaysMax = NULL, $durationDaysMin = NULL, $language = NULL, $latitude = NULL, $longitude = NULL, $page = NULL, $pax = NULL, $perPage = NULL, $priceMax = NULL, $priceMin = NULL, $published = NULL, $query = NULL, $sort = NULL, $type = NULL)
 {
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/v1/products';
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('category' => $category, 'city' => $city, 'country' => $country, 'currency' => $currency, 'date_end' => $dateEnd, 'date_start' => $dateStart, 'deleted' => $deleted, 'distance' => $distance, 'duration_days_max' => $durationDaysMax, 'duration_days_min' => $durationDaysMin, 'language' => $language, 'latitude' => $latitude, 'longitude' => $longitude, 'page' => $page, 'pax' => $pax, 'per_page' => $perPage, 'price_max' => $priceMax, 'price_min' => $priceMin, 'published' => $published, 'query' => $query, 'sort' => $sort, 'type' => $type));
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'BeMyGuest.SDK.v1', 'Accept' => 'application/json', 'X-Authorization' => Configuration::$xAuthorization);
     //call on-before Http callback
     $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl);
     if ($this->getHttpCallBack() != null) {
         $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest);
     }
     //and invoke the API call request to fetch the response
     $response = Request::get($_queryUrl, $_headers);
     //call on-after Http callback
     if ($this->getHttpCallBack() != null) {
         $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body);
         $_httpContext = new HttpContext($_httpRequest, $_httpResponse);
         $this->getHttpCallBack()->callOnAfterRequest($_httpContext);
     }
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('Wrong Arguments', $_httpContext);
     } else {
         if ($response->code == 401) {
             throw new APIException('Unauthorized', $_httpContext);
         } else {
             if ($response->code == 403) {
                 throw new APIException('Forbidden', $_httpContext);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('Resource Not Found', $_httpContext);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('Method Not Allowed', $_httpContext);
                     } else {
                         if ($response->code == 410) {
                             throw new APIException('Resource No Longer Available', $_httpContext);
                         } else {
                             if ($response->code < 200 || $response->code > 208) {
                                 //[200,208] = HTTP OK
                                 throw new APIException("HTTP Response Not OK", $_httpContext);
                             }
                         }
                     }
                 }
             }
         }
     }
     $mapper = $this->getJsonMapper();
     return $mapper->map($response->body, new Models\GETProductsResponse());
 }
コード例 #18
0
ファイル: Texts.php プロジェクト: radiegtya/rapid-api-php
 public static function get($id, $params = null, $headers = null)
 {
     $response = Request::get(Rapid::getUrl(self::$route . '/' . $id), $headers, $params);
     return Response::make($response);
 }
コード例 #19
0
 /**
  * Show information on a specific country
  * @param  string     $countryCodeA3     Required parameter: The three letter identifier for the country
  * @return mixed response from the API call*/
 public function getCountry($countryCodeA3)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::BASEURI;
     $queryBuilder = Config::get('voxbone.base_uri');
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/inventory/country/{countryCodeA3}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('countryCodeA3' => $countryCodeA3));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('user-agent' => 'APIMATIC 2.0', 'Accept' => 'application/json');
     //prepare API request
     $response = Request::get($queryUrl, $headers);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         return $response;
     }
     return $response->body;
 }
コード例 #20
0
 /**
  * Download a given monthly call report using MTOM
  * @param  string     $fileName     Required parameter: The name of the report to download
  * @return binary response from the API call*/
 public function getCdrsFile($fileName)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::BASEURI;
     $queryBuilder = Config::get('voxbone.base_uri');
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/cdrs/cdrsfile/{fileName}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('fileName' => $fileName));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('User-Agent' => 'APIMATIC 2.0');
     //prepare API request
     $response = Request::get($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     //$response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         return $response;
     }
     return $response->body;
 }
コード例 #21
0
 /**
  * TODO: type endpoint description here
  * @param  string                   $userID        Required parameter: TODO: type description here
  * @param  string                   $contactListID Required parameter: TODO: type description here
  * @return ContacListDetailResponse response from the API call*/
 public function getAssociatedContact($userID, $contactListID)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::baseUri();
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/v3/users/{User ID}/contact_lists/{Contact List ID}/contacts';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('User ID' => $userID, 'Contact List ID' => $contactListID));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('User-Agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'Authorization' => sprintf('Bearer %1$s', Configuration::token()));
     //prepare API request
     $response = Request::get($queryUrl, $headers);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         throw new APIException("HTTP Response code: " . $response->code . ". " . $response->body->error_description, $response->code);
     }
     return $response->body;
 }
コード例 #22
0
ファイル: files.php プロジェクト: PhenixH/PufferPanel
 /**
  * Returns the contents of a given folder in GSD.
  *
  * @return bool|array
  */
 protected final function _retrieveFolderListing()
 {
     try {
         $attached_folder = !is_null($this->params['dir']) ? $this->params['dir'] : "/";
         $request = Unirest\Request::get("https://" . $this->server->nodeData('fqdn') . ":" . $this->server->nodeData('daemon_listen') . "/server/directory/" . $attached_folder, array('X-Access-Token' => $this->server->getData('daemon_secret'), 'X-Access-Server' => $this->server->getData('hash')));
         return $request;
     } catch (\Exception $e) {
         Debugger::log($e);
         return false;
     }
 }
コード例 #23
0
ファイル: routes.php プロジェクト: PhenixH/PufferPanel
     $response->body($core->twig->render('node/403.html'))->send();
     return;
 }
 $file = (object) pathinfo($request->param('file'));
 if (!in_array($file->extension, $core->files->editable())) {
     $service->flash('<div class="alert alert-danger">You do not have permission to edit files with that extension.</div>');
     $response->redirect('/node/files')->send();
     return;
 }
 if (in_array($file->dirname, array(".", "./", "/"))) {
     $file->dirname = "";
 } else {
     $file->dirname = trim($file->dirname, '/') . "/";
 }
 try {
     $unirest = \Unirest\Request::get("https://" . $core->server->nodeData('fqdn') . ":" . $core->server->nodeData('daemon_listen') . "/server/file/" . rawurlencode($file->dirname . $file->basename), array("X-Access-Token" => $core->server->getData('daemon_secret'), "X-Access-Server" => $core->server->getData('hash')));
     if ($unirest->code !== 200 || !isset($unirest->body->contents)) {
         $service->flash('<div class="alert alert-danger">An error was encountered when trying to retrieve this file for editing. [HTTP\\1.1 ' . $unirest->code . ']</div>');
         $response->redirect('/node/files')->send();
         return;
     }
     /*
      * Display Page
      */
     $response->body($core->twig->render('node/files/edit.html', array('flash' => $service->flashes(), 'server' => $core->server->getData(), 'node' => $core->server->nodeData(), 'xsrf' => $core->auth->XSRF(), 'file' => $request->param('file'), 'extension' => $file->extension, 'directory' => $file->dirname, 'contents' => $unirest->body->contents)))->send();
 } catch (\Exception $e) {
     \Tracy\Debugger::log($e);
     $service->flash('<div class="alert alert-danger">The daemon does not appear to be online currently. Please try again.</div>');
     $response->redirect('/node/files')->send();
     return;
 }
コード例 #24
0
 protected function UnirestapiLogin($content)
 {
     $apiUrl = $this->_apiUrl;
     $url = $apiUrl . "/login";
     $headers = array("Content-Type" => "application/x-www-form-urlencoded;", "Accept" => "application/json");
     $response = Unirest\Request::get($url, $headers, $content);
     if ($response->code == '200') {
         return $response->body;
     }
     return false;
 }
コード例 #25
0
ファイル: DieselUp.php プロジェクト: xcopy/dieselup
 /**
  * @param string $url
  * @param string $method
  * @param string $body
  * @return string
  * @throws ErrorException
  */
 protected function request($url, $method = Method::GET, $body = null)
 {
     $this->output->writeln(sprintf('<fg=white>%s %s</>', $method, $url));
     /** @var $response Unirest\Response */
     $response = strtoupper($method) === Method::POST ? Request::post($url, [], $body) : Request::get($url);
     $result = (string) $response->body;
     $document = new \DOMDocument();
     $document->loadHTML($result);
     $xpath = new \DomXpath($document);
     $errors = $xpath->query('//div[contains(@class, "errorwrap")]');
     if ($errors->length) {
         throw new \ErrorException($errors->item(0)->getElementsByTagName('p')->item(0)->textContent);
     }
     return $result;
 }
コード例 #26
0
 public function getResultsOverrideAction($data_connector_id, $method = null, $url = null, $parms_in = null, $clean = false)
 {
     if ($url == null) {
         $url = $this->url;
     }
     if ($method == null) {
         $method = $this->method;
     }
     $data_connector = DataConnector::findFirstByid($data_connector_id);
     $storage = (array) json_decode($data_connector->storage, true);
     if (array_key_exists('token_expiry', $storage)) {
         if (time() > $storage['token_expiry']) {
             $authenticatorName = "\\PRIME\\Authenticators\\" . $this->authenticator . "Controller";
             $authenticatorController = new $authenticatorName();
             $authenticatorController->initialize();
             $authenticatorController->RefreshTokenAction($data_connector_id);
             $storage = (array) json_decode($data_connector->storage, true);
         }
     }
     if ($clean) {
         $parameters = array();
     } else {
         $parameters = (array) json_decode($data_connector->parameters, true);
     }
     $parms_in = (array) json_decode($parms_in, true);
     foreach ($parms_in as $key => $value) {
         $parameters[$key] = $value;
     }
     if (array_key_exists('rest', $parameters)) {
         foreach ($parameters['rest'] as $item) {
             $url = $url . "/" . $item;
         }
     }
     $query_parms = array();
     if (array_key_exists('query', $parameters)) {
         $query_parms = $parameters['query'];
     }
     $header_parms = array();
     if (array_key_exists('headers', $parameters)) {
         $header_parms = $parameters['headers'];
     }
     $body_parms = array();
     if (array_key_exists('body', $parameters)) {
         $body_parms = $parameters['body'];
     }
     if (array_key_exists('Authorization', $storage)) {
         $header_parms['Authorization'] = $storage['Authorization'];
     }
     switch ($method) {
         case "POST":
             $response = \Unirest\Request::post($url, $header_parms, $body_parms);
             break;
         case "PUT":
             $response = \Unirest\Request::put($url, $header_parms, $body_parms);
             break;
         default:
             $response = \Unirest\Request::get($url, $header_parms, $query_parms);
     }
     $this->view->disable();
     return $response->raw_body;
 }
コード例 #27
0
ファイル: Numberapi.php プロジェクト: cloudapidev/apibay
 /**
  * @param integer $number
  */
 public function getInfo($url, $inputs = array(), $number = null)
 {
     $url = setApiUrl($url, $number);
     $response = Unirest\Request::get($url, $this->_headers, $inputs);
     // 		return $response;
     if ($response->code == 200) {
         return $response->body;
     }
     return 0;
 }
コード例 #28
0
ファイル: routes.php プロジェクト: PhenixH/PufferPanel
        $query->save();
        /*
         * Send Email
         */
        $core->email->buildEmail('new_password', array('NEW_PASS' => $password, 'EMAIL' => $query->content))->dispatch($query->content, Settings::config()->company_name . ' - New Password');
        $service->flash('<div class="alert alert-success">You should recieve an email within the next 5 minutes (usually instantly) with your new account password. We suggest changing this once you log in.</div>');
        $response->redirect('/auth/login')->send();
    }
});
$klein->respond('POST', '/auth/password', function ($request, $response, $service) use($core) {
    if ($core->auth->XSRF($request->param('xsrf')) !== true) {
        $service->flash('<div class="alert alert-warning">The XSRF token recieved was not valid. Please make sure cookies are enabled and try your request again.</div>');
        $response->redirect('/auth/password')->send();
    }
    try {
        $unirest = Unirest\Request::get("https://www.google.com/recaptcha/api/siteverify", array(), array('secret' => Settings::config('captcha_priv'), 'response' => $request->param('g-recaptcha-response'), 'remoteip' => $request->ip()));
        if (!isset($unirest->body->success) || !$unirest->body->success) {
            $service->flash('<div class="alert alert-danger">The spam prevention was not filled out correctly. Please try it again.</div>');
            $response->redirect('/auth/password')->send();
            return;
        }
    } catch (\Exception $e) {
        $service->flash('<div class="alert alert-danger">Unable to query the captcha validation servers. Please try it again.</div>');
        $response->redirect('/auth/password')->send();
        return;
    }
    $query = ORM::forTable('users')->where('email', $request->param('email'))->findOne();
    if ($query) {
        $key = $core->auth->keygen('30');
        ORM::forTable('account_change')->create()->set(array('type' => 'password', 'content' => $request->param('email'), 'key' => $key, 'time' => time() + 14400))->save();
        $core->email->buildEmail('password_reset', array('IP_ADDRESS' => $request->ip(), 'GETHOSTBY_IP_ADDRESS' => gethostbyaddr($request->ip()), 'PKEY' => $key))->dispatch($request->param('email'), Settings::config()->company_name . ' - Reset Your Password');
コード例 #29
-1
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $username = $input->getOption('username');
     $password = $input->getOption('password');
     $date = $input->getOption('date');
     if (is_null($username) || is_null($password)) {
         throw new \InvalidArgumentException('Both username and password are required.');
     }
     // Make request to get the access_token
     $body = array("username" => $username, "password" => $password);
     $response = Unirest\Request::post("https://app.mybasis.com/login", "", $body);
     $response_cookie = $response->headers['Set-Cookie'][0];
     $cookieArray = explode(';', $response_cookie);
     $accessToken = explode('=', $cookieArray[0])[1];
     // Make request to get the data
     $metricURL = 'https://app.mybasis.com/api/v1/metricsday/me?day=' . $date . '&padding=0' . '&heartrate=true' . '&steps=true' . '&calories=true' . '&gsr=true' . '&skin_temp=true' . '&air_temp=true';
     $headers = array("Accept" => "application/json");
     Unirest\Request::cookie("access_token=" . $accessToken);
     $response = Unirest\Request::get($metricURL, $headers, $body);
     print_r($response->raw_body);
     //        print_r($response->code);        // HTTP Status code
     //        print_r($response->headers);     // Headers
     //        print_r($response->body);        // Parsed body
     //        print_r($response->raw_body);    // Unparsed body
     //
     //
     //        echo $metricURL;
 }
コード例 #30
-2
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     HTTPRequest::verifyPeer(env('UNIREST_VERIFYPEER'));
     $response = HTTPRequest::get($this->url);
     $posts = $response->body->data->children;
     foreach ($posts as $post) {
         //            dd($post->data->stickied);
         if (!$post->data->stickied) {
             Quote::firstorCreate(["content" => $post->data->title, "author" => $post->data->author, "source" => 'https://www.reddit.com' . $post->data->permalink]);
         }
     }
 }