本文整理汇总了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;
}
示例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());
}
示例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";
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例11: testValidatedSsl
function testValidatedSsl()
{
$curl = new Curl();
$curl->setValidateSsl(true);
$response = $curl->get('https://www.facebook.com/');
$this->assertEquals(200, $response->headers['Status-Code']);
}
示例12: function
function test_error()
{
assert_throws('CurlException', function () {
$curl = new Curl();
$curl->get('diaewkaksdljf-invalid-url-dot-com.com');
});
}
示例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;
}
示例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;
}
示例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
}