本文整理汇总了PHP中Curl::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::close方法的具体用法?PHP Curl::close怎么用?PHP Curl::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl
的用法示例。
在下文中一共展示了Curl::close方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProblemInfo
public static function getProblemInfo($problemId)
{
// 新建一个curl
$ch = new Curl();
$url = 'http://poj.org/problem?id=' . $problemId;
$html = $ch->get($url);
if (empty($html) || $ch->error()) {
$ch->close();
return false;
}
$ch->close();
$problemInfo = array();
$matches = array();
// 获取标题
preg_match('/<div class="ptt" lang="en-US">(.*)<\\/div>/sU', $html, $matches);
$problemInfo['title'] = '';
if (!empty($matches[1])) {
$problemInfo['title'] = trim($matches[1]);
}
// 获取来源
preg_match('/<a href="searchproblem\\?field=source.*>(.*)<\\/a>/sU', $html, $matches);
$problemInfo['source'] = '';
if (!empty($matches[1])) {
$problemInfo['source'] = trim($matches[1]);
}
$problemInfo['problem_id'] = $problemId;
$problemInfo['problem_code'] = $problemId;
return $problemInfo;
}
示例2: getProblemInfo
public static function getProblemInfo($problemId)
{
// 新建一个curl
$ch = new Curl();
$url = 'http://acm.hdu.edu.cn/showproblem.php?pid=' . $problemId;
$html = $ch->get($url);
if (empty($html) || $ch->error()) {
$ch->close();
return false;
}
$ch->close();
$problemInfo = array();
$matches = array();
// 获取标题
preg_match('/<td align=center><h1 style=\'color:#1A5CC8\'>(.*)<\\/h1>/sU', $html, $matches);
$problemInfo['title'] = '';
if (!empty($matches[1])) {
$problemInfo['title'] = trim($matches[1]);
$problemInfo['title'] = iconv('GBK', 'UTF-8', $problemInfo['title']);
}
// 获取来源
preg_match('/>Source.*<a.*\\/search.php.*>(.*)<\\/a>/sU', $html, $matches);
$problemInfo['source'] = '';
if (!empty($matches[1])) {
$problemInfo['source'] = trim($matches[1]);
$problemInfo['source'] = iconv('GBK', 'UTF-8', $problemInfo['source']);
}
$problemInfo['problem_id'] = $problemId;
$problemInfo['problem_code'] = $problemId;
return $problemInfo;
}
示例3: CallMethod
/**
* Вызов метода ApiVK
* @param $sMethod
* @param $mParams
* @return bool|mixed
*/
private function CallMethod($sMethod, $mParams)
{
if (is_array($mParams)) {
if (!isset($mParams['access_token'])) {
if (!$this->sAccessToken) {
return false;
}
$mParams['access_token'] = $this->sAccessToken;
}
$oCurl = new Curl();
$oCurl->SetUrl('https://api.vk.com/method/' . $sMethod);
$oCurl->SetPostfields($mParams);
$sResult = $oCurl->GetResponseBody(true);
} else {
$sParams = $mParams;
if (!strpos($mParams, 'access_token')) {
if (!$this->sAccessToken) {
return false;
}
$sParams = $mParams . '&access_token=' . $this->sAccessToken;
}
$oCurl = new Curl();
$oCurl->SetUrl('https://api.vk.com/method/' . $sMethod . '?' . $sParams);
$sResult = $oCurl->GetResponseBody(true);
}
if ($sResult === false) {
throw new Exception($oCurl->Error());
}
$oCurl->close();
return json_decode($sResult);
}
示例4: testCurlWrapperCanDoHttpQueries
function testCurlWrapperCanDoHttpQueries()
{
$curl = new Curl(self::TEST_VALID_URL);
$curl->setopt(CURLOPT_PROXY, $this->proxy);
$this->assertTrue($curl->setopt(CURLOPT_RETURNTRANSFER, 1));
$this->assertTrue($curl->setopt_array(array(CURLOPT_TIMEOUT => self::CURL_TIMEOUT, CURLOPT_FOLLOWLOCATION => true)));
$result = $curl->exec();
$this->assertStringStartsWith('<!doctype html>', $result);
$curl->close();
$this->assertFalse($curl->hasHandle());
}
示例5: ip
public static function ip($ip)
{
$url = 'http://apis.baidu.com/rtbasia/ip_type/ip_type?ip=' . $ip;
$curl = new Curl();
$curl->setHeader("apikey", "29ddcb64dbe2f42764115b28941d2154");
$curl->get($url);
$curl->close();
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
} else {
return $curl->response;
}
}
示例6: getProblemInfo
public static function getProblemInfo($problemCode)
{
// 新建一个curl
$ch = new Curl();
$url = 'http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=' . $problemCode;
$html = $ch->get($url);
if (empty($html) || $ch->error()) {
$ch->close();
return false;
}
$ch->close();
$problemInfo = array();
$matches = array();
// 获取标题
preg_match('/<span class="bigProblemTitle">(.*)<\\/span>/sU', $html, $matches);
$problemInfo['title'] = '';
if (!empty($matches[1])) {
$problemInfo['title'] = trim($matches[1]);
}
// 获取来源
preg_match('/Source:.*<strong>(.*)<\\/strong>/sU', $html, $matches);
if (empty($matches[1])) {
preg_match('/Contest:.*<strong>(.*)<\\/strong>/sU', $html, $matches);
}
$problemInfo['source'] = '';
if (!empty($matches[1])) {
$problemInfo['source'] = trim($matches[1]);
}
// 获取$problemId
preg_match('/"\\/onlinejudge\\/submit.do\\?problemId=(\\d+)"/sU', $html, $matches);
$problemInfo['problem_id'] = 0;
if (!empty($matches[1])) {
$problemInfo['problem_id'] = $matches[1];
}
$problemInfo['problem_code'] = $problemCode;
$problemInfo['remote'] = StatusVars::REMOTE_ZOJ;
return $problemInfo;
}
示例7: send
/**
* Sends single text message.
*
* @param string $number recipient's phone number
* @param string $message the message
* @param null $signature sender's signature
* @param null $phoneback sender's phone number
* @return bool
* @throws SmsGatewayException
*/
public function send($number, $message, $signature = null, $phoneback = null)
{
$curl = new Curl();
// Step 2
$responseStep2 = $curl->sendRequest(self::ENDPOINT . '?page=sendsms', array('phoneno' => $number, 'message' => $message, 'signature' => $signature, 'phoneback' => $phoneback, 'action' => 'verify', 'ads_check1' => 'js_off', 'ads_check2' => 'js_off'));
$phpsessid = $curl->getHtmlProperty($responseStep2, 'PHPSESSID');
// Step 3
$curl->sendRequest(self::ENDPOINT, array('PHPSESSID' => $phpsessid, 'action' => 'confirmbyuser'));
// Step 4
$responseStep4 = $curl->sendRequest(self::ENDPOINT, array('operator' => 'donotknow', 'action' => 'confirmprovider'));
$imagecode = $curl->getHtmlProperty($responseStep4, 'imgcode');
// Step 5
$curl->sendRequest(self::ENDPOINT . '?a=sent', array('imgcode' => $imagecode, 'action' => 'useraccepted'));
$curl->close();
return true;
}
示例8: Curl
<?php
include '../lib/Curl.php';
include '../lib/Curl/Share.php';
/**
* curl_share_init() example
*
* http://php.net/manual/en/function.curl-share-init.php#refsect1-function.curl-share-init-examples
*/
// Create cURL share handle and set it to share cookie data
$sh = new Curl\Share();
$sh->setopt(CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
// Initialize the first cURL handle and assign the share handle to it
$ch1 = new Curl("http://example.com/");
$ch1->setopt(CURLOPT_SHARE, $sh);
// Execute the first cURL handle
$ch1->exec();
// Initialize the second cURL handle and assign the share handle to it
$ch2 = new Curl("http://php.net/");
$ch2->setopt(CURLOPT_SHARE, $sh);
// Execute the second cURL handle
// all cookies from $ch1 handle are shared with $ch2 handle
$ch2->exec();
// Close the cURL share handle
$sh->close();
// Close the cURL handles
$ch1->close();
$ch2->close();
示例9: array
function curlNet2($method, $url, $param = array(), $ssl = FALSE)
{
require dirname(__FILE__) . '/ext/curl.php';
$curl = new Curl();
$exMethod = strtolower($method);
if ($ssl == TRUE) {
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
}
$curl->{$exMethod}($url, $param);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
$curl->close();
} else {
return $curl->response;
$curl->close();
unset($curl);
}
}
示例10: item
/**
*
* @static
* @param string $id
* @return object|null
*/
public static function item($id)
{
self::$_params = 'key=' . self::$_apiKey . '&id=' . $id;
Curl::init();
$jsonGet = Curl::get(self::$_apiUrl . '/item?' . self::$_params);
Curl::close();
if ($jsonGet) {
$jsonData = json_decode($jsonGet);
if (isset($jsonData->error)) {
showError($jsonData->error, 'API Error', 500);
} else {
return $jsonData;
}
}
return NULL;
}
示例11: close
public function close()
{
$this->curl->close();
}
示例12: dirname
# limitations under the License.
*/
require_once dirname(__DIR__) . "/classes/Requires.php";
//Get settings
$result = MySQLQueries::get_settings();
$row = MySQLConnection::fetch_object($result);
$instance_key = null;
if (isset($row->data)) {
$row->data = json_decode($row->data);
if (isset($row->data->instance_key) && !empty($row->data->instance_key)) {
$instance_key = $row->data->instance_key;
} else {
$instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
$data = array("instance_key" => $instance_key, "default_ssh_username" => $row->data->default_ssh_username, "default_ssh_port" => $row->data->default_ssh_port, "default_interpreter" => $row->data->default_interpreter, "timezone_offset" => $row->data->timezone_offset, "timezone_daylight_savings" => $row->data->timezone_daylight_savings);
MySQLQueries::edit_settings(json_encode((object) $data));
}
} else {
$instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
$data = array("instance_key" => $instance_key);
MySQLQueries::edit_settings(json_encode((object) $data));
}
$servers = array();
$result = MySQLQueries::get_servers();
while ($row = MySQLConnection::fetch_object($result)) {
$servers[] = $row;
}
$payload = '{"event":"' . $instance_key . '","properties":{"token":"678f0669ff58d890eeb50633c91a633d","distinct_id":"' . $instance_key . '","ip":"' . Functions::get_remote_ip() . '","servers":"' . count($servers) . '","version":"' . Version::app . '","ip-address":"' . Functions::get_remote_ip() . '","mp_name_tag":"' . $instance_key . '","time":"' . time() . '"}}';
$curl = new Curl();
$curl->get_request("https://api.mixpanel.com/track/?data=" . base64_encode($payload));
$curl->close();
echo '{"instance_key":"' . $instance_key . '"}';
示例13: close
public function close()
{
parent::close();
$this->unsetClassVars();
}
示例14: Curl
<?php
include '../lib/Curl.php';
/**
* curl_init() example
*
* http://php.net/manual/en/function.curl-init.php#refsect1-function.curl-init-examples
*/
// create a new cURL resource
$ch = new Curl();
// set URL and other appropriate options
$ch->setopt(CURLOPT_URL, "http://www.example.com/");
$ch->setopt(CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$ch->exec();
// close cURL resource, and free up system resources
$ch->close();