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


PHP Curl::setOpt方法代码示例

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


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

示例1: index

 /**
  * PAGE: index
  * This method handles what happens when you move to http://yourproject/home/index (which is the default page btw)
  */
 public function index()
 {
     $redirected = false;
     //check if there is an error
     if ($_GET['error'] != '') {
         //load error page!
         die("<h1>Whoops, something went wrong, you can refresh to see if it fixes it otherwise check back later.</h1>");
     }
     if (isset($_GET['appSource'])) {
         $redirected = true;
         $appSource = (int) $_GET['appSource'];
     }
     if (!$redirected) {
         if (isset($_GET['id']) && $_GET['id'] != "") {
             $extraParameters['id'] = $_GET['id'];
         }
         if (isset($_GET['fbSource'])) {
             $extraParameters['appSource'] = $_GET['appSource'];
         }
         if (isset($_GET['traffic_source']) && $_GET['traffic_source'] != '') {
             $extraParameters['traffic_source'] = $_GET['traffic_source'];
         }
     }
     $signedRequest = null;
     if (isset($_POST['signed_request'])) {
         $signedRequest = self::parseSignedRequest($_POST['signed_request']);
     }
     Log::add('Signed request: ' . $signedRequest);
     //check if user_id
     if ($signedRequest === null) {
         //we need to get one!
         $url = Config::get('facebook.appurl') . "?" . http_build_query($_GET);
         header("location: " . $url);
         exit;
     }
     if (!isset($signedRequest['user_id']) || $signedRequest['user_id'] == '') {
         $redirectUrl = self::buildUrl($extraParameters);
         $oAuthUrl = "https://www.facebook.com/dialog/oauth?";
         $oAuthUrl .= http_build_query(array_filter(array('client_id' => Config::Get('facebook.appid'), 'redirect_uri' => self::buildUrl($extraParameters), 'scope' => 'user_friends,email')));
         die("<script>top.location.href = '" . $oAuthUrl . "';</script>");
     }
     $fbCurlReq = new Curl();
     $fbCurlReq->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $fbCurlReq->get('https://graph.facebook.com/me?access_token=' . $signedRequest['oauth_token']);
     if ($fbCurlReq->error) {
         Log::add('Error fb user profile ' . $fbCurlReq->error_code . ': ' . $fbCurlReq->error_message);
     } else {
         $dataArray = $fbCurlReq->response;
     }
     Log::add('dataArray = ' . print_r($dataArray, true));
     //check too see if this is a post :)
     $game = new Game();
     $game->loadGame((array) $dataArray, 'facebook', $extraParameters);
 }
开发者ID:sherdog,项目名称:wnd,代码行数:58,代码来源:home.php

示例2: send

 public function send($url, $method, array $parameters = [], array $postParameters = [], array $header = [], $content = '')
 {
     $this->curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $method = strtolower($method);
     $finalUrl = strpos($url, '//') !== false ? $url : $this->url . $url;
     if (!empty($this->authorization) && empty($header['Authorization'])) {
         $authClass = 'Bennsel\\WindowsAzureCurl\\Service\\Authorization\\' . $this->authorization;
         $class = new $authClass($this->settings);
         $header['Authorization'] = $class->getAuthorizationString($url, $method, $parameters, $header);
     }
     if ($content && is_object($content) && method_exists($content, 'toArray')) {
         $parameters = $content->toArray();
     }
     foreach ($header as $key => $value) {
         $this->curl->setHeader($key, $value);
     }
     $orgHeader = $header;
     $r = $this->curl->{$method}($finalUrl, $parameters ?: $postParameters);
     if ($this->curl->http_status_code == 301) {
         $this->url = $this->curl->response_headers['Location'];
         return $this->send($url, $method, $parameters, $postParameters, $orgHeader, $content);
     }
     return ResponseModelMapping::create($url, $r);
 }
开发者ID:bennsel,项目名称:azure-for-php-curl,代码行数:25,代码来源:RestClient.php

示例3: getWeChatIp

 public static function getWeChatIp()
 {
     $api = 'https://api.weixin.qq.com/cgi-bin/getcallbackip';
     $url_query = '?access_token=' . self::$token->getToken();
     $curl = new Curl();
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE);
     $curl->get($api . $url_query);
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         if (isset($curl->response->errcode)) {
             switch ($curl->response->errcode) {
                 case '40002':
                     die($curl->response->errmsg);
                     break;
                 case '40013':
                     die($curl->response->errmsg);
                     break;
                 case '40125':
                     die($curl->response->errmsg);
                     break;
                 default:
                     die('未知错误');
                     break;
             }
         } else {
             return $curl->response;
         }
     }
 }
开发者ID:shsrain,项目名称:ShsrainWeChat,代码行数:31,代码来源:WeChat.php

示例4: __construct

 /**
  * Make the call
  *
  * @author Koen Blokland Visser
  *
  * @param $hash
  * @param $callId
  *
  * @return array
  */
 public function __construct($hash, $callId)
 {
     $curl = new Curl();
     $curl->setHeader('Content-Type', 'application/json');
     $curl->setHeader('Accept', 'application/json');
     $curl->setHeader('Hash', $hash);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $curl->get('https://api.voipgrid.nl/api/clicktodial/' . $callId . '/');
     /** @var array $response */
     $this->response = json_decode($curl->response, true);
 }
开发者ID:koenster,项目名称:php-voys,代码行数:21,代码来源:VoysCallStatus.php

示例5: getAccessToken

 protected function getAccessToken()
 {
     $url_query = '?grant_type=' . $this->grant_type;
     $url_query .= '&appid=' . $this->appid;
     $url_query .= '&secret=' . $this->secret;
     $curl = new Curl();
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE);
     $curl->get($this->token_api . $url_query);
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         if (isset($curl->response->errcode)) {
             switch ($curl->response->errcode) {
                 case '40002':
                     die($curl->response->errmsg);
                     break;
                 case '40013':
                     die($curl->response->errmsg);
                     break;
                 case '40125':
                     die($curl->response->errmsg);
                     break;
                 default:
                     throw new TokenExpiredException("未知错误");
                     break;
             }
         } else {
             return $curl->response;
         }
     }
 }
开发者ID:shsrain,项目名称:ShsrainWeChat,代码行数:32,代码来源:Token.php

示例6: 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

示例7: all

 public function all($year)
 {
     $curl = new Curl();
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $curl->get('http://localhost/stripe/index.php/api/v1/earnings/index/' . $year);
     return $curl->response;
 }
开发者ID:JohnOscar-Mendoza,项目名称:lb_cms,代码行数:8,代码来源:Earnings_model.php

示例8: appointmentsTimeline

 public function appointmentsTimeline()
 {
     $curl = new Curl();
     $curl->setHeader("X-Parse-Application-Id", "yPPe3Uv46pKNnrTc7I6xArFHi8EQ8cdz4Kw3JGkX");
     $curl->setHeader("X-Parse-REST-API-Key", "7PJB1F4g8aFSv5f8e0gSMwi9Ghv2AeAkTW0O50pe");
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $curl->get('http://52.24.133.167/stripe/index.php/api/v1/history/appointments');
     return $curl->response;
 }
开发者ID:JohnOscar-Mendoza,项目名称:lb_cms,代码行数:10,代码来源:Dashboard_model.php

示例9: __construct

 /**
  * Api constructor.
  *
  * @param string $apiKey API Key
  * @param string $environment API environment
  */
 public function __construct($apiKey, $environment)
 {
     ArgValidator::assert($apiKey, ['string', 'notEmpty']);
     ArgValidator::assert($environment, ['string', 'notEmpty']);
     $this->curl = new Curl();
     $this->curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $this->curl->setUserAgent('Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0');
     $this->apiUrl = $this->getApiUrl($environment);
     $this->apiKey = $apiKey;
 }
开发者ID:gennadyx,项目名称:shop-logistics.ru-api,代码行数:16,代码来源:Api.php

示例10: getRemoteHtml

 public function getRemoteHtml()
 {
     $curl = new Curl();
     $curl->setOpt(CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1');
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $curl->get($this->url);
     $this->getDate = date('Y-m-d H:i:s');
     if ($curl->error) {
         return 'Error: ' . $curl->error_code . ': ' . $curl->error_message;
     } else {
         return $curl->response;
     }
 }
开发者ID:chyuaner,项目名称:PHP-Crawler-Example,代码行数:13,代码来源:Fubon.php

示例11: __construct

 public function __construct($login, $hash, $subdomain, ICookieContainer $cookieContainer)
 {
     $this->_login = $login;
     $this->_hash = $hash;
     $this->_subdomain = $subdomain;
     $this->cookieContainer = $cookieContainer;
     $this->_curl = new Curl();
     $this->_curl->setUserAgent('amoCRM-API-client/1.0');
     $this->_curl->setHeader('Content-Type', 'application/json');
     $this->_curl->setOpt(CURLOPT_HEADER, false);
     $this->_curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
     $this->_curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
     $this->auth();
 }
开发者ID:nanodesu88,项目名称:amocrm,代码行数:14,代码来源:AmoCrm.php

示例12: __construct

 public function __construct($iniFile)
 {
     $this->loadBaseMods();
     $this->loadIni($iniFile);
     $this->pdo = new lw\Pdo($this, $this->configArray['Pdo']);
     $this->curl = new \Curl\Curl();
     //Set this option because WAMP sucks
     $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     //Set this because all the returns are expecting JSON string, and Curl updated to do it automatically.
     $this->curl->setJsonDecoder(function ($response) {
         return $response;
     });
     $this->url = $this->configArray['Site']['url'];
     $this->title = $this->configArray['Site']['title'];
     Core::setApiKey($this->configArray['Site']['APIKEY']);
 }
开发者ID:jlawrence11,项目名称:wowApi,代码行数:16,代码来源:FactoryLw.php

示例13: _html

 protected function _html()
 {
     $curl = new Curl();
     $curl->setHeader('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36');
     $curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
     $html = $curl->get($this->url);
     return $html;
 }
开发者ID:vNative,项目名称:vnative,代码行数:8,代码来源:Scrape.php

示例14: fetch

 /**
  * Get remote file hash.
  *
  * @param string $path
  *
  * @return string
  */
 public function fetch($path, $force = false)
 {
     $url = $this->url . $path;
     // Cached?
     if ($force || !isset($this->cache[$path])) {
         $curl = new Curl();
         $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
         $curl->setOpt(CURLOPT_AUTOREFERER, true);
         $curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
         $curl->get($url);
         if ($curl->error) {
             return false;
         }
         $this->cache[$path] = md5($curl->response);
     }
     return $this->cache[$path];
 }
开发者ID:arall,项目名称:cmsdiff,代码行数:24,代码来源:Fetcher.php

示例15: 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


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