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


PHP Curl::setopt方法代码示例

本文整理汇总了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();
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:38,代码来源:Update.php

示例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);
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:12,代码来源:Customer.php

示例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);
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:12,代码来源:Account.php

示例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;
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:13,代码来源:Webhook.php

示例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;
     }
 }
开发者ID:slayerz,项目名称:triosms,代码行数:26,代码来源:Triosms.php

示例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);
 }
开发者ID:Gyvastis,项目名称:twitter-trends-scraper,代码行数:18,代码来源:TwitterTrends.php

示例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;
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:13,代码来源:Token.php

示例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);
 }
开发者ID:fmedeiros95,项目名称:xapo,代码行数:14,代码来源:Deposit.php

示例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;
 }
开发者ID:emptyWang,项目名称:umeng-message-sdk-php,代码行数:10,代码来源:Client.php

示例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);
开发者ID:oz4n,项目名称:elastic-api,代码行数:17,代码来源:TestCurl.php

示例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 ;
开发者ID:igogo978,项目名称:sfs3-jsonBoard,代码行数:31,代码来源:page.php


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