当前位置: 首页>>代码示例>>PHP>>正文


PHP Curl::close方法代码示例

本文整理汇总了PHP中Curl\Curl::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::close方法的具体用法?PHP Curl::close怎么用?PHP Curl::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Curl\Curl的用法示例。


在下文中一共展示了Curl::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: request

 /**
  * Execute a request against the url.
  *
  * @param string $url
  * @param array  $params
  *
  * @return mixed
  */
 public function request($url, array $params = [])
 {
     $this->curl->get($url, $params);
     $this->curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $response = $this->curl->response;
     $this->curl->close();
     return $response;
 }
开发者ID:kamaroly,项目名称:shift,代码行数:16,代码来源:Recaptcha.php

示例2: getWithParams

 /**
  * HTTP GET wrapper for Curl.
  * For requests with additional query parameters.
  *
  * @param string $url URL to GET request to.
  * @return mixed Response data.
  */
 public function getWithParams($url)
 {
     $curl = new Curl();
     $curl->get($this->endpoint . $url . '&api_token=' . $this->token);
     $curl->close();
     return json_decode($curl->response);
 }
开发者ID:maciekmp,项目名称:pipedrive-php-api,代码行数:14,代码来源:HTTP.php

示例3: run

 public static function run($method, $params = [])
 {
     self::$defaultParam = ['method' => $method, 'module' => 'API', 'token_auth' => STAT_API_TOKEN, 'format' => 'JSON', 'expanded ' => true, 'idSite' => 1, 'filter_offset' => \yii::$app->request->get('filter_offset', 0), 'filter_limit' => \yii::$app->request->get('filter_limit', 50)];
     $params['formatDate'] = isset($params['formatDate']) ? $params['formatDate'] : null;
     if ($params['formatDate'] !== false) {
         self::formatDate();
     }
     unset($params['formatDate']);
     $params = array_merge(self::$defaultParam, $params);
     $params = array_filter($params);
     $curl = new Curl();
     $curl->setJsonDecoder(function ($response) {
         $json_obj = json_decode($response, true);
         if (!($json_obj === null)) {
             $response = $json_obj;
         }
         return $response;
     });
     $curl->get(STAT_API_URL, $params);
     $curl->close();
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         return $curl->response;
     }
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:26,代码来源:API.php

示例4: create

 /**
  * Create user cache.
  *
  * @param string $user Twitter screen name
  * @return bool If successful true
  * @throws CacheException Any errors
  */
 public function create($user)
 {
     try {
         $path = config("cache.path") . "/{$user}";
         $json_file = "{$path}/data.json";
         if (!$this->exists($user)) {
             mkdir($path);
         }
         if (!file_exists($json_file)) {
             touch($json_file);
         }
         $response = $this->twistOAuth->get("users/show", ["id" => $user]);
         $image_url = str_replace("_normal", "", $response->profile_image_url_https);
         $info = new SplFileInfo($image_url);
         $curl = new Curl();
         $curl->setUserAgent(SaveTweet::APP_NAME . "/" . SaveTweet::APP_VERSION . " with PHP/" . PHP_VERSION);
         $curl->download($image_url, "{$path}/icon.{$info->getExtension()}");
         $curl->close();
         $data = ["name" => $response->name, "screen_name" => $response->screen_name, "id" => $response->id_str, "icon" => config("cache.http_path") . "/{$response->id_str}/icon.{$info->getExtension()}", "org_icon" => $image_url, "update_at" => time()];
         $json = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
         (new SplFileObject($json_file, "w"))->fwrite($json);
         return true;
     } catch (RuntimeException $e) {
         $this->_catch($e);
     }
 }
开发者ID:Hiroto-K,项目名称:SaveTweet,代码行数:33,代码来源:Cache.php

示例5: apiCall

 /**
  * API Call.
  *
  * @param string $path
  *
  * @throws Exception HTTP Error
  *
  * @return string
  */
 private static function apiCall($path)
 {
     $curl = new Curl();
     $curl->get(self::API_URL . $path);
     $curl->close();
     if ($curl->error) {
         throw new Exception('HTTP Error: ' . $curl->error_code . ': ' . $curl->error_message);
     }
     return $curl->response;
 }
开发者ID:arall,项目名称:cmsdiff,代码行数:19,代码来源:GitHub.php

示例6: request

	private function request($url, $data) {
		$curl = new Curl();
		$curl->get($url, $data);
		$response = $curl->response;
		$http_response_header = $curl->httpStatusCode;
		$curl->close();
		if ($http_response_header == 200) {
			return $response;
		}
		return null;
	}
开发者ID:Neoseeker,项目名称:SteamAPI,代码行数:11,代码来源:SteamPrivateAPI.php

示例7: execute

 /**
  * @return boolean
  */
 public function execute()
 {
     $this->curl = new Curl();
     $this->curl->setOpt(CURLOPT_ENCODING, 'gzip');
     $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $this->curl->setOpt(CURLOPT_HTTPHEADER, array('Accept: application/xml'));
     $this->prepareRequest();
     if (!$this->xmlRequest) {
         $this->lastError = new Exception('Request XML is not defined.');
         return false;
     }
     if (!isset(static::$API_METHOD) || !static::$API_METHOD) {
         $this->lastError = new Exception('API method is not defined.');
         return false;
     }
     $url = rtrim(static::ENDPOINT, '/') . '/' . static::ENDPOINT_VERSION . '/' . static::$API_METHOD;
     $data = array();
     if (static::$HTTP_METHOD === EANFacade::HTTP_METHOD_POST) {
         $data['xml'] = XMLUtils::SXEasXML($this->xmlRequest);
         $url .= '?' . Utils::httpBuildQuery3986($this->params);
     } else {
         $data = array_merge($this->params, array('xml' => XMLUtils::SXEasXML($this->xmlRequest)));
     }
     if (static::$HTTP_METHOD === EANFacade::HTTP_METHOD_GET) {
         $this->curl->get($url, $data);
         $this->curl->close();
     } else {
         if (static::$HTTP_METHOD === EANFacade::HTTP_METHOD_POST) {
             $this->curl->post($url, $data);
             $this->curl->close();
         } else {
             $this->lastError = new Exception('Invalid method for API call.');
             return false;
         }
     }
     if ($this->curl->error) {
         $this->lastError = new Exception($this->curl->errorMessage);
         return false;
     }
     try {
         if ($this->curl->response instanceof SimpleXMLElement) {
             $this->xmlResponse = $this->curl->response;
         } else {
             $this->xmlResponse = new SimpleXMLElement($this->curl->response);
         }
     } catch (Exception $e) {
         $this->lastError = $e;
         return false;
     }
     $this->lastError = null;
     $this->prepareResponse();
     return true;
 }
开发者ID:GitHub-Dharam,项目名称:ean-api-client,代码行数:56,代码来源:EANAbstractQuery.php

示例8: prim_address

 public function prim_address($token, $acc_id)
 {
     $curl = new Curl();
     $curl->setopt(CURLOPT_URL, "https://v2.api.xapo.com/accounts/{$acc_id}/primary_address/");
     $curl->setopt(CURLOPT_RETURNTRANSFER, true);
     $curl->setopt(CURLOPT_HEADER, false);
     $curl->setopt(CURLOPT_HTTPHEADER, ["Authorization: Bearer {$token}"]);
     $curl->_exec();
     $curl->close();
     $response = $curl->response;
     return json_decode($response);
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:12,代码来源:Account.php

示例9: post

 private function post($json, $headers)
 {
     $curl = new Curl();
     $curl->setHeader('Content-Type', 'application/json');
     $curl->setHeader('apikey', strval($this->apiKey));
     $curl->setHeader('token', strval($this->merchantToken));
     $curl->setHeader('Authorization', $headers['authorization']);
     $curl->setHeader('nonce', $headers['nonce']);
     $curl->setHeader('timestamp', $headers['timestamp']);
     $curl->post($this->uri, $json);
     $curl->close();
     return $curl->response;
 }
开发者ID:parkgaram,项目名称:payeezy-l,代码行数:13,代码来源:PayeezyApi.php

示例10: ip

 public static function ip($ip)
 {
     $url = 'http://apis.baidu.com/rtbasia/ip_type/ip_type?ip=' . $ip;
     $curl = new Curl();
     $curl->setHeader("apikey", "58d0d55af6ee8cda005ec2d674ff0db2");
     $curl->get($url);
     $curl->close();
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         return $curl->response;
     }
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:13,代码来源:IpType.php

示例11: disable

 public function disable($token, $id)
 {
     $curl = new Curl();
     $curl->setopt(CURLOPT_URL, "https://v2.api.xapo.com/webhooks/{$id}/disable");
     $curl->setopt(CURLOPT_RETURNTRANSFER, true);
     $curl->setopt(CURLOPT_HEADER, false);
     $curl->setopt(CURLOPT_POST, true);
     $curl->setopt(CURLOPT_HTTPHEADER, ["Authorization: Bearer {$token}"]);
     $curl->_exec();
     $response = $curl->response;
     $curl->close();
     return $response;
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:13,代码来源:Webhook.php

示例12: new

 public function new($redirect_uri)
 {
     $curl = new Curl();
     $curl->setopt(CURLOPT_RETURNTRANSFER, true);
     $curl->setopt(CURLOPT_HEADER, false);
     $curl->setopt(CURLOPT_URL, 'https://v2.api.xapo.com/oauth2/token');
     $curl->setopt(CURLOPT_POST, true);
     $curl->setopt(CURLOPT_POSTFIELDS, "grant_type=client_credentials&redirect_uri={$redirect_uri}");
     $curl->setopt(CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded', "Authorization: Basic {$this->hash}"]);
     $curl->_exec();
     $curl->close();
     return json_decode($curl->response)->access_token;
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:13,代码来源:Token.php

示例13: update

 public function update($token, $addr, $amount)
 {
     $curl = new Curl();
     $curl->setopt(CURLOPT_URL, "https://v2.api.xapo.com/addresses/{$addr}?payment_threshold={$amount}");
     $curl->setopt(CURLOPT_RETURNTRANSFER, true);
     $curl->setopt(CURLOPT_HEADER, false);
     $curl->setopt(CURLOPT_CUSTOMREQUEST, 'PATCH');
     $curl->setopt(CURLOPT_POSTFIELDS, ['payment_threshold' => $amount]);
     $curl->setopt(CURLOPT_HTTPHEADER, ["Authorization: Bearer {$token}"]);
     $curl->_exec();
     $response = $curl->response;
     $curl->close();
     return json_decode($response);
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:14,代码来源:Deposit.php

示例14: _register

 protected function _register()
 {
     $user = new User(array("name" => RequestMethods::post("name"), "email" => RequestMethods::post("email"), "gender" => RequestMethods::post("gender", ""), "fbid" => RequestMethods::post("fbid", ""), "live" => 1, "admin" => 0));
     $fb = new Curl();
     $access_token = RequestMethods::post("access_token");
     $fb->get('https://graph.facebook.com/me', ['access_token' => $access_token, 'fields' => 'name,email,gender,id']);
     $response = $fb->response;
     $fb->close();
     if ($response->error || $response->id != $user->fbid) {
         throw new \Exception("Error Processing Request");
     } else {
         $user->save();
     }
     return $user;
 }
开发者ID:SwiftDeal,项目名称:fbfunapp,代码行数:15,代码来源:auth.php

示例15: send

 /**
  * Send SMS from specified account
  *
  * @param string $recipient : recipient mobile number
  * @param string $message : message to be sent
  * @param string $mode : account to send the SMS from
  * @param string $format : content type
  * @return string containing cURL response
  */
 public function send($recipient, $message, $mode = '', $format = '')
 {
     /* make sure credit is available before proceed */
     $balance = $this->balance(empty($mode) ? $this->mode : $mode);
     if ($balance == 0) {
         return false;
     }
     $curl = new Curl\Curl();
     $curl->setopt(CURLOPT_RETURNTRANSFER, true);
     $curl->get($this->url . 'index.php/api/bulk_mt', array('api_key' => $this->token, 'action' => 'send', 'to' => $recipient, 'msg' => $message, 'sender_id' => $this->sender, 'content_type' => empty($format) ? $this->format : $format, 'mode' => empty($mode) ? $this->mode : $mode));
     $curl->close();
     if ($curl->error) {
         return false;
     } else {
         return $curl->response;
     }
 }
开发者ID:slayerz,项目名称:triosms,代码行数:26,代码来源:Triosms.php


注:本文中的Curl\Curl::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。