本文整理汇总了PHP中Curl\Curl::setopt方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::setopt方法的具体用法?PHP Curl::setopt怎么用?PHP Curl::setopt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl\Curl
的用法示例。
在下文中一共展示了Curl::setopt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Init CLDR data and download default language
*/
public function init()
{
if (!is_file($file = $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'core.zip')) {
$fp = fopen($file, "w");
$curl = new Curl();
$curl->setopt(CURLOPT_FILE, $fp);
$curl->setopt(CURLOPT_FOLLOWLOCATION, true);
$curl->setopt(CURLOPT_HEADER, false);
$curl->get(self::ZIP_CORE_URL);
if ($curl->error) {
throw new \Exception("Failed to download '" . self::ZIP_CORE_URL . "'.");
}
fclose($fp);
}
//extract ONLY supplemental json files
$archive = new \ZipArchive();
if ($archive->open($file) === true) {
for ($i = 0; $i < $archive->numFiles; $i++) {
$filename = $archive->getNameIndex($i);
if (preg_match('%^supplemental\\/(.*).json$%', $filename)) {
if (!is_dir($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . dirname($filename))) {
mkdir($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . dirname($filename), 0777, true);
}
if (!file_exists($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename)) {
copy("zip://" . $file . "#" . $filename, $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename);
$this->newDatasFile[] = $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename;
}
}
}
$archive->close();
} else {
throw new \Exception("Failed to unzip '" . $file . "'.");
}
$this->generateSupplementalDatas();
}
示例2: update
public function update($c_id, $fname = '', $mname = '', $lname = '', $gen = '', $avatar = '', $addl1 = '', $addl2 = '', $city = '', $state = '', $country = '', $zip = '', $dob = '')
{
$curl = new Curl();
$curl->setopt(CURLOPT_URL, "https://v2.api.xapo.com/customers/{$c_id}/?first_name={$fname}middle_name={$mname}&last_name={$lname}&gender={$gen}&avatar={$avatar}&address_line_1={$addl1}&address_line_2={$addl2}&city={$city}&state={$state}&country_iso3={$country}&zip_code={$zip}&date_of_birth={$dob}");
$curl->setopt(CURLOPT_RETURNTRANSFER, true);
$curl->setopt(CURLOPT_HEADER, false);
$curl->setopt(CURLOPT_CUSTOMREQUEST, 'PATCH');
$curl->_exec();
$response = $curl->response;
$curl->close();
return json_decode($response);
}
示例3: 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);
}
示例4: 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;
}
示例5: 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;
}
}
示例6: scrape
public function scrape($locale = 'en-us', $user_agent = false, $proxy = false)
{
$curl = new Curl();
$curl->setHeader('Accept-Language', $locale);
$curl->setopt(CURLOPT_SSL_VERIFYPEER, FALSE);
if ($user_agent) {
$curl->setOpt(CURLOPT_USERAGENT, $user_agent);
}
if ($proxy) {
$curl->setOpt(CURLOPT_PROXY, $proxy);
// $curl->setOpt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
}
$curl->get($this->trends_url);
if ($curl->error) {
throw new FailedRetrieveTrendsException('Error #' . $curl->error_code . ': ' . $curl->error_message);
}
$this->parseTrendsFromResponse($curl->response);
}
示例7: 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;
}
示例8: 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);
}
示例9: curl_post
public function curl_post($sUrl, $aPOSTParam, $timeout = 5)
{
$curl = new Curl();
if ($timeout) {
$curl->setopt(CURLOPT_CONNECTTIMEOUT, $timeout);
}
$curl->post($sUrl, $aPOSTParam);
$curl->close();
return $curl->error ? false : $curl->response;
}
示例10: tempnam
<?php
require '../../vendor/autoload.php';
use Curl\Curl;
$cookiefile = tempnam("/tmp", "cookies");
$user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1';
$curl = new Curl();
$curl->setUserAgent($user_agent);
$curl->setOpt(CURLOPT_HEADER, 0);
$curl->setopt(CURLOPT_RETURNTRANSFER, TRUE);
$curl->setopt(CURLOPT_FOLLOWLOCATION, TRUE);
$curl->setopt(CURLOPT_SSL_VERIFYPEER, FALSE);
$curl->setopt(CURLOPT_SSL_VERIFYHOST, FALSE);
$curl->setopt(CURLOPT_COOKIEFILE, $cookiefile);
$curl->setopt(CURLOPT_COOKIEJAR, $cookiefile);
$get = $curl->get('google.com');
var_dump($curl);
示例11: Curl
require __DIR__ . '/vendor/autoload.php';
use Curl\Curl;
$downloadBaseUrl = "http://163.17.39.135/data/school/board/";
$sfs3BoardUrl = "http://163.17.39.135/modules/json/jsonBoard/index.php";
$myLog = "download/ajax.log";
//file_put_contents($wFile,($_GET));
$obj = json_decode(urldecode(implode('', $_GET)));
//$obj->{'articleId'}
//$obj->{'page'}
if (isset($obj->{'page'})) {
$page = $obj->{'page'};
} else {
$page = 0;
}
$curl = new Curl();
$curl->setopt(CURLOPT_RETURNTRANSFER, TRUE);
$curl->setopt(CURLOPT_SSL_VERIFYPEER, FALSE);
$curl->get($sfs3BoardUrl, array('page' => $page));
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
} else {
if (isset($obj->{'articleId'})) {
//file_put_contents($myLog,($obj->{'articleId'}));
//$jsonFile = sprintf("json/board%d.json",$obj->{'page'});
//$jsonObj = json_decode(file_get_contents($jsonFile));
$jsonObj = json_decode($curl->response);
//file_put_contents($myLog,$jsonObj);
$downloadFiles = array();
$i = 0;
foreach ($jsonObj->records as $article) {
//print $article->articleId ;