コード例 #1
0
 public function getCitiesData(Request $request)
 {
     $data = Curl::get($this->api_url . "getcities", [], false, ['VERBOSE' => true]);
     $data = json_decode($data);
     $data = (object) $data;
     return view('web.select_cities', compact('data'));
 }
コード例 #2
0
ファイル: Gulliver.php プロジェクト: fcolella/docker
 /**
  *
  * @param string $service
  * @param string $method
  * @param array $parameters
  * @return array|bool
  */
 static function call($service = "", $method = "", $parameters = [], $type = 'get')
 {
     //	Check if cache exist
     $response = Cache::get(self::$cache_name);
     if (null == $response) {
         //	Curl call
         if ('post' == $type) {
             $resp = Curl::to(config('services.gulliver.host') . ':' . config('services.gulliver.port') . '/' . $service . (false == empty($method) ? '/' . $method : ""))->withData($parameters)->withOption('TIMEOUT', self::$timeout)->withOption('FAILONERROR', false)->withOption('RETURNTRANSFER', self::$returntransfer)->withOption('ENCODING', self::$encoding)->asJson()->post();
         } else {
             $resp = Curl::to(config('services.gulliver.host') . ':' . config('services.gulliver.port') . '/' . $service . (false == empty($method) ? '/' . $method : ""))->withData($parameters)->withOption('TIMEOUT', self::$timeout)->withOption('FAILONERROR', false)->withOption('RETURNTRANSFER', self::$returntransfer)->withOption('ENCODING', self::$encoding)->get();
         }
         #print_pre(['to'=>config('services.gulliver.host').':'.config('services.gulliver.port').'/'.$service.((false==empty($method)) ? '/'.$method : ""),'response'=>$response]);
         //	Check response
         if (false == $resp) {
             self::$error = true;
             return false;
         }
         #print_pre($response,1,1);
         //	Decode the response
         $response = json_decode($resp, true);
         #dd(['response'=>$response,'method'=>$method]);
         //	Check for json error
         if (json_last_error() != JSON_ERROR_NONE) {
             self::$error = 'json error: ' . json_last_error() . '<br>' . print_pre($resp);
             return false;
         } else {
             unset($resp);
         }
         //	Check error
         if (false == empty($response['errors'])) {
             self::$error = false == empty($response['errors'][0]['description']) ? $response['errors'][0]['description'] : true;
             return false;
         }
         //	Check data
         if (true == empty($response['data'])) {
             self::$error = 'Empty data node in response';
             return false;
         }
         //	Check method
         if (false == empty($method) && true == empty($response['data'][$method])) {
             self::$error = 'Empty method node in response';
             return false;
         }
         //	return array
         if (false == empty($method)) {
             $response = (array) $response['data'][$method];
         } else {
             $response = (array) $response['data'];
         }
         //	Cache Store ?
         if (0 < self::$cache_ttl) {
             Cache::put(self::$cache_name, $response, self::$cache_ttl);
         }
     }
     //
     self::reset();
     //	return
     return $response;
 }
コード例 #3
0
ファイル: apicalls.php プロジェクト: CharlieMCR/tramatic
 public static function eventful()
 {
     $key = self::eventful_key();
     $response = Curl::get('http://api.eventful.com/json/events/search?app_key=' . $key . '&location=53.4779,-2.2437&within=5&page_size=100&date=Future&sort_order=popularity&include=categories&category=music');
     if (!empty($response)) {
         $eventful = json_decode($response)->events->event;
         return $eventful;
     }
 }
コード例 #4
0
ファイル: helpers.php プロジェクト: lucy-udalykh/samples
function getShortenUrl($url)
{
    $request_url = 'https://api-ssl.bitly.com/v3/shorten?&apiKey=rrr&login=bpnext&longUrl=' . urlencode($url);
    $shorten_url_result = json_decode(Curl::get($request_url));
    if (!empty($shorten_url_result->data->url)) {
        return $shorten_url_result->data->url;
    } else {
        return $url;
    }
}
コード例 #5
0
 /**
  * Default request
  *
  * @param string $url The url
  * @return mixed
  */
 public static function request($url)
 {
     $response = Curl::to($url . '&personalkey=' . self::$_apiKey)->withOption('SSL_VERIFYPEER', env('API_SSL_ALBERTHEIJN', true))->asJson()->get();
     return $response;
 }
コード例 #6
0
 public function notify()
 {
     Curl::to($this->webhook_url)->withData(["payload" => json_encode($this->payload)])->post();
 }
コード例 #7
0
 public function catchImages()
 {
     $source = $this->request->source;
     $item = array("state" => "", "url" => "", "size" => "", "title" => "", "original" => "", "source" => "");
     $list = array();
     foreach ($source as $imgUrl) {
         $return_img = $item;
         $return_img['source'] = $imgUrl;
         $imgUrl = htmlspecialchars($imgUrl);
         $imgUrl = str_replace("&amp;", "&", $imgUrl);
         if (strpos($imgUrl, "http") !== 0) {
             $return_img['state'] = "错误的链接";
             array_push($list, $return_img);
             continue;
         }
         $result = Curl::to("{$imgUrl}")->withOption('REFERER', 'http://www.baidu.com')->get();
         $file = $result->get('content');
         $info = $result->get('info');
         $type = last(explode('/', $info['content_type']));
         $this->path = $this->assemblyPath();
         $path = sys_get_temp_dir() . '/' . md5(uniqid());
         $content = Image::make($file)->save($path);
         if ($url = $this->uploadProcess(File::get("{$path}"))) {
             $return_img['state'] = 'SUCCESS';
             $return_img['url'] = $url;
             array_push($list, $return_img);
         } else {
             array_push($list, ['state' => "无法写入文件"]);
         }
     }
     return response()->json(array('state' => count($list) ? 'SUCCESS' : 'ERROR', 'list' => $list));
 }
コード例 #8
-1
ファイル: WebIOPi.php プロジェクト: kmarcisz/outside-lights
 private function setFunction($gpioNumber, $mode)
 {
     return Curl::to($this->endpoint . $gpioNumber . '/function/' . $mode)->withOption('USERPWD', $this->authString)->post();
 }