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


PHP Curl::get方法代码示例

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


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

示例1: translate

 public function translate($phrase, $lang_from = "ru", $lang_to = "en")
 {
     $params = ['key' => $this->config['key'], 'text' => $phrase, 'lang' => "{$lang_from}-{$lang_to}"];
     $response = json_decode($this->curl->get("api/v1.5/tr.json/translate", $params), true);
     if ($response['code'] != 200) {
         throw new Exception($this->error_codes[$this->curl->last_http_code] ?: "Unknown error", $this->curl->last_http_code);
     }
     return $response;
 }
开发者ID:xxxcoltxxx,项目名称:test,代码行数:9,代码来源:Translate.php

示例2: download

 /**
  * @param Url $url
  *
  * @return File
  * @throws DownloadFailedException
  */
 public function download(Url $url)
 {
     $this->output->writeInfo(sprintf('Downloading %s', $url));
     $response = $this->curl->get($url);
     if ($response->getHttpCode() !== 200) {
         throw new DownloadFailedException(sprintf('Download failed (HTTP status code %s) %s', $response->getHttpCode(), $response->getErrorMessage()));
     }
     if (empty($response->getBody())) {
         throw new DownloadFailedException('Download failed - response is empty');
     }
     return new File($this->getFilename($url), $response->getBody());
 }
开发者ID:paul-schulleri,项目名称:phive,代码行数:18,代码来源:FileDownloader.php

示例3: run

 public function run()
 {
     $pageURL = $this->getUrl();
     $pageHTML = $this->curl->get($pageURL);
     $emails = $this->parser->getEmails($pageHTML);
     $countEmails = count($emails);
     $URLs = $this->parser->getURLs($pageHTML);
     $this->model->saveEmails($emails);
     $this->model->saveURLs($URLs);
     echo "Download emails from address '{$pageURL}' is complete.\n";
     echo "There are {$countEmails} records.\n";
 }
开发者ID:mkrdip,项目名称:email-scraper,代码行数:12,代码来源:AutomaticRobot.php

示例4: download

 /**
  * @param string $keyId
  *
  * @return string
  * @throws DownloadFailedException
  */
 public function download($keyId)
 {
     $params = ['search' => '0x' . $keyId, 'op' => 'get', 'options' => 'mr'];
     foreach ($this->keyServers as $keyServer) {
         $this->output->writeInfo(sprintf('Trying %s', $keyServer));
         $result = $this->curl->get(new Url($keyServer . self::PATH), $params);
         if ($result->getHttpCode() == 200) {
             $this->output->writeInfo('Sucessfully downloaded key');
             return $result->getBody();
         }
         $this->output->writeWarning(sprintf('Failed with status code %s: %s', $result->getHttpCode(), $result->getErrorMessage()));
     }
     throw new DownloadFailedException(sprintf('Key %s not found on key servers', $keyId));
 }
开发者ID:paul-schulleri,项目名称:phive,代码行数:20,代码来源:GnupgKeyDownloader.php

示例5: 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;
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:29,代码来源:PojRemoteAdapter.class.php

示例6: process_user

 public function process_user($username, $password, $facility_code)
 {
     $curl = new Curl();
     $response = array();
     //Get Supplier
     $supplier = $this->get_supplier($facility_code);
     if ($supplier == "kemsa") {
         //Use nascop url
         $url = $this->default_url;
         $post = array("email" => $username, "password" => $password);
         $url = $this->default_url . 'sync/user';
         $curl->post($url, $post);
     } else {
         //Use escm url
         $curl->setBasicAuthentication($username, $password);
         $curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE);
         $url = $this->default_url . 'user/' . $username;
         $curl->get($url);
     }
     //Handle Response
     if ($curl->error) {
         $response['error'] = TRUE;
         $response['content'] = array($curl->error_code);
     } else {
         $response['error'] = FALSE;
         $response['content'] = json_decode($curl->response, TRUE);
     }
     return json_encode($response);
 }
开发者ID:OmondiKevin,项目名称:ADT_MTRH,代码行数:29,代码来源:cdrr_logic.php

示例7: getAllGroups

 public function getAllGroups()
 {
     $url = $this->apiUrl . "/cgi-bin/groups/get?access_token={$this->access_token}";
     $content = Curl::get($url);
     $result = json_decode($content, true);
     return $this->get($result);
 }
开发者ID:Colorado-rom,项目名称:hdphp,代码行数:7,代码来源:Group.php

示例8: get

 function get($url, $get = array())
 {
     $curl = Curl::get($url, $get);
     $curl->option(array(CURLOPT_COOKIESESSION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_COOKIEJAR => $this->cookie, CURLOPT_HTTPHEADER => $this->header, CURLOPT_CONNECTTIMEOUT => 100));
     $r = $curl->call();
     return $r->raw_body;
 }
开发者ID:rocketyang,项目名称:mincms,代码行数:7,代码来源:GetMail.php

示例9: total

 public function total()
 {
     $url = $this->apiUrl . "/cgi-bin/material/get_materialcount?access_token={$this->access_token}";
     $content = Curl::get($url);
     $result = json_decode($content, true);
     return $this->get($result);
 }
开发者ID:ChenHuaPHP,项目名称:ZOLshop,代码行数:7,代码来源:Material.php

示例10: getUserLists

 public function getUserLists($next_openid = '')
 {
     $url = $this->apiUrl . "/cgi-bin/user/get?access_token={$this->access_token}&next_openid={$next_openid}";
     $content = Curl::get($url);
     $result = json_decode($content, true);
     return $this->get($result);
 }
开发者ID:ChenHuaPHP,项目名称:ZOLshop,代码行数:7,代码来源:User.php

示例11: testValidatedSsl

 function testValidatedSsl()
 {
     $curl = new Curl();
     $curl->setValidateSsl(true);
     $response = $curl->get('https://www.facebook.com/');
     $this->assertEquals(200, $response->headers['Status-Code']);
 }
开发者ID:nickl-,项目名称:curl,代码行数:7,代码来源:CurlTest.php

示例12: function

 function test_error()
 {
     assert_throws('CurlException', function () {
         $curl = new Curl();
         $curl->get('diaewkaksdljf-invalid-url-dot-com.com');
     });
 }
开发者ID:leebivip,项目名称:dns,代码行数:7,代码来源:curl_test.php

示例13: 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;
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:31,代码来源:HduRemoteAdapter.class.php

示例14: expressTakeDetail

 public function expressTakeDetail($userID)
 {
     $curl = new Curl();
     $expressTakeDetail = $curl->get($this->url['expressTakeUser'] . "?userID=" . $userID);
     $expressListUsers = $curl->get($this->url['expressListUsers']);
     foreach ($expressTakeDetail as $key => &$takeDetail) {
         $createUserID = $takeDetail->express_create_user_id;
         $fromUserID = $takeDetail->express_from_user_id;
         $toUserID = $takeDetail->express_to_user_id;
         $takeDetail->express_create_user_id_attr = $expressListUsers->{$createUserID};
         $takeDetail->express_from_user_id_attr = $expressListUsers->{$fromUserID};
         $takeDetail->express_to_user_id_attr = $expressListUsers->{$toUserID};
         $takeDetail->express_take_status_attr = self::$error[$takeDetail->express_take_status];
     }
     return $expressTakeDetail;
 }
开发者ID:aslijiasheng,项目名称:jasongo,代码行数:16,代码来源:express_service_model.php

示例15: get_link

 public function get_link()
 {
     // Check Captcha
     $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6LfXLBwTAAAAAKog-gWVMOmDJKhHGEMCELdR-Ukn&response=" . Input::get('g-recaptcha-response'));
     $obj = json_decode($response);
     if ($obj->success == false) {
         echo 'Captcha error';
         exit;
     } else {
         libxml_use_internal_errors(true);
         require_once app_path('Libraries/Curl.php');
         $url = Input::get('url');
         $url = str_replace("http://", "https://", $url);
         // step 1: Login
         $curl = new \Curl();
         $curl->get('https://www.fshare.vn');
         $session_id = $curl->getCookie('session_id');
         $doc = new \DOMDocument();
         $doc->loadHTML($curl->response);
         $xpath = new \DOMXpath($doc);
         $array = $xpath->query("//*[@id='login-form']//*[@name='fs_csrf']");
         foreach ($array as $value) {
             $fs_csrf = $value->getAttribute('value');
         }
         $curl->setCookie('session_id', $session_id);
         $curl->post('https://www.fshare.vn/login', array("fs_csrf" => $fs_csrf, "LoginForm[email]" => "phandung1111059@gmail.com", "LoginForm[password]" => "7508286", "LoginForm[rememberMe]" => "0", "yt0" => "Đăng nhập"));
         $session_id = $curl->getCookie('session_id');
         $curl->setCookie('session_id', $session_id);
         $curl->post('https://www.fshare.vn/login', array("fs_csrf" => $fs_csrf, "LoginForm[email]" => "phandung1111059@gmail.com", "LoginForm[password]" => "7508286", "LoginForm[rememberMe]" => "0", "yt0" => "Đăng nhập"));
         echo "Step 1: Login - Done !!! <br>";
         // step 2: Get link download
         $curl->get($url);
         $doc = new \DOMDocument();
         $doc->loadHTML($curl->response);
         $xpath = new \DOMXpath($doc);
         $array = $xpath->query("//*[@id='download-form']/div[1]/input");
         foreach ($array as $value) {
             $fs_csrf = $value->getAttribute('value');
         }
         $split_url = explode('/', $url);
         $curl->post('https://www.fshare.vn/download/get', array("fs_csrf" => $fs_csrf, "DownloadForm[pwd]" => "", "DownloadForm[linkcode]" => end($split_url), "ajax" => "download-form", "undefined" => "undefined"));
         echo "Step 2: Get Link Download - Done !!! <br><br>";
         echo "URL: " . @$curl->response->url;
         return redirect()->away($curl->response->url);
     }
     // END IF CHECK RECAPTCHA
 }
开发者ID:npdung,项目名称:Get-link,代码行数:47,代码来源:GetlinkController.php


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