Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class cURL
- {
- public $email;
- public $senha;
- var $callback = false;
- public function getStr($string,$start,$end)
- {
- $str = explode($start,$string);
- $str = explode($end,$str[1]);
- return $str[0];
- }
- private function setCallback($func_name)
- {
- $this->callback = $func_name;
- }
- public function doRequest($method, $url)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
- curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
- curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
- curl_setopt($ch, CURLOPT_COOKIEJAR, getcwd().'/cookie.txt');
- curl_setopt($ch, CURLOPT_COOKIEFILE, getcwd().'/cookie.txt');
- curl_setopt($ch, CURLOPT_REFERER, '');
- curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
- if ($method == 'POST')
- {
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "username={$this->email}&password={$this->senha}&recaptchaResponse=FALSE");
- }
- $data = curl_exec($ch);
- curl_close($ch);
- if ($data)
- {
- if ($this->callback)
- {
- $callback = $this->callback;
- $this->callback = false;
- return call_user_func($callback, $data);
- }
- else
- {
- return $data;
- }
- }
- else
- {
- return curl_error($ch);
- }
- }
- public function get($url)
- {
- return $this->doRequest('GET', $url, 'NULL');
- }
- public function post($url)
- {
- return $this->doRequest('POST', $url);
- }
- }
- $cURL = new cURL;
- $cURL->email = "Email";
- $cURL->senha = "Senha";
- echo $cURL->post('https://www.netshoes.com.br/login');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement