本文整理汇总了PHP中Curl::setCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::setCookie方法的具体用法?PHP Curl::setCookie怎么用?PHP Curl::setCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl
的用法示例。
在下文中一共展示了Curl::setCookie方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
}
示例2: setCookie
public function setCookie($key, $value)
{
$this->curl->setCookie($key, $value);
return $this;
}
示例3: testCookies
public function testCookies()
{
$this->curl->setCookie('mycookie', 'yum');
$this->assertTrue($this->server('GET', array('test' => 'cookie', 'key' => 'mycookie')) === 'yum');
}
示例4: Curl
<?php
require 'Curl.php';
// step 1
$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 $v) {
$fs_csrf = $v->getAttribute('value');
}
// step 2
$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');
// step 3
$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"));
$curl->get('https://www.fshare.vn/account/profile');
$doc = new DOMDocument();
$doc->loadHTML($curl->response);
$xpath = new DOMXpath($doc);
$array = $xpath->query("//*[@id='ProfileForm_name']");
foreach ($array as $v) {
$test = $v->getAttribute('value');
}