Jump to content

Search the Community

Showing results for tags 'curl login'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. I'm new to using cURL and its hard to find good resources for it. What I'm trying to do is login to a remote site, by having curl do the login form and then send back that it was successful. The code I have doesn't seem to work and only tries to show the main page of the site $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://m.algadon.com/login.php?act=login'); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, "username=kontol&password=kontol"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_COOKIEJAR, '$ckfile'); //could be empty, but cause problems on some hosts curl_setopt($ch, CURLOPT_COOKIEFILE, '$ckfile'); //could be empty, but cause problems on some hosts $answer = curl_exec($ch); if (curl_error($ch)) { echo curl_error($ch); } //another request preserving the session curl_setopt($ch, CURLOPT_URL, 'http://m.algadon.com/login.php?act=login'); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_POSTFIELDS, ""); $answer = curl_exec($ch); if (curl_error($ch)) { echo curl_error($ch); }
  2. Hi, Im using a web gateway for a D&D game, and I want to access it via curl to automate one really time-eating activity, like clicking every x minutes for me. And got stuck at that point, when the game's gateway does not sees curl to actually be logged after curl sent the login data, cookies are on, but gateway seems to not leting me in. im using crul from few years to login to many things, i think im doing it right, but somehow it does not works, please, can somebody tell me why it does not work, i do everything how it should be done ? This is main code: <?php require_once '_shoelace.php'; require_once ROOT . '_include/class.curl.php'; set_time_limit('400'); $h = array( 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0', 'Cache-Control: no-cache', 'Connection: keep-alive', 'Content-Encoding: gzip', 'Content-Type: text/xml; charset=UTF-8', 'Transfer-Encoding: chunked', 'Vary: Accept-encoding' ); $url = 'https://gateway.playneverwinter.com'; $url = 'http://gateway.playneverwinter.com/#char%28mychar@mylogin%29/'; echo '<base href="https://gateway.playneverwinter.com/#/characterselect">'; $c = new Curl($url); $x = $c->httpheader($h)->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->post('user=mylogin%40o2.pl&pw=mypass')->exec(); // $x = '{"result":"user_login_ok","destURL":"http://gateway.playneverwinter.com/","idBrowser":"HqZ7PdKTmZc2rjQYiAac4sI3ZokJfyCtpCxCKzIgB","idTicket":1764876376,"idAccount":9820944}'; $x = json_decode($x); if ($x) { $url = "http://gateway.playneverwinter.com/?account={$x->idAccount}&ticket={$x->idTicket}&browser={$x->idBrowser}"; $c = new Curl($url); $x = $c->httpheader($h)->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); $url = 'http://gateway.playneverwinter.com/lang.js?cb=18d2f832bed403993f7d6ae7021a0ebepl'; $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); $url = 'http://gateway.playneverwinter.com/socket.io/1/?t=' . date('U');; $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); $t = explode(':', $x); $url = 'http://gateway.playneverwinter.com/socket.io/1/xhr-polling/' . $t[0] . '?t=' . date('U'); $c = new Curl($url); // $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->post('5:::{"name":"Client_OneTimeCode","args":[{"code":"36809","name":"Maa Brawser"}]}')->exec(); // krumo($x); $url = 'http://gateway.playneverwinter.com/socket.io/1/xhr-polling/' . $t[0] . '?t=' . date('U'); $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); krumo($x); $url = 'http://gateway.playneverwinter.com/socket.io/1/xhr-polling/' . $t[0] . '?t=' . date('U'); $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); krumo($x); $url = 'http://gateway.playneverwinter.com/socket.io/1/xhr-polling/' . $t[0] . '?t=' . date('U'); $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); krumo($x); } die(); $url = 'http://gateway.playneverwinter.com/time'; $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); $url = 'http://gateway.playneverwinter.com/dataTables.js'; $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); krumo($x); $url = 'http://gateway.playneverwinter.com/socket.io/1/?t=1390649083641'; $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); $t = explode(':', $x); $url = 'http://gateway.playneverwinter.com/socket.io/1/xhr-polling/' . $t[0] . '?t=1390657023475'; $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); $url = 'http://gateway.playneverwinter.com/socket.io/1/xhr-polling/' . $t[0] . '?t=' . date('U'); $c = new Curl($url); $x = $c->ssl(3)->cookies($_C['cookie_dir'] . 'nw.txt')->exec(); krumo($x); ?> And this is my overlay for curl: <?php Class Curl { public $_header = FALSE; public $_nobody = FALSE; public $dir; public $cache = FALSE; public $cache_time = FALSE; public $cache_gzip = TRUE; function __construct($url = null) { global $_C; if (!function_exists('curl_init')) { trigger_error('PHP was not built with --with-curl, rebuild PHP to use the curl class.', E_USER_ERROR) ; }else{ $this->agent = "Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1"; $this->agent = "Mozilla/5.0 (Windows NT 6.0; rv:22.0) Gecko/20100101 Firefox/22.0"; $this->ch = curl_init(); $this->url = $url; curl_setopt($this->ch, CURLOPT_URL, $this->url); curl_setopt($this->ch, CURLOPT_USERAGENT, $this->agent); curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($this->ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: 89.37.54.44", "HTTP_X_FORWARDED_FOR: 89.37.54.44")); } } function proxy($proxy) { curl_setopt($this->ch, CURLOPT_PROXY, $proxy); //182.253.72.161 81 return $this; } function cache_file($u) { if (isset($this->file) && $this->file) $u = $this->file; $u = str_replace(array('http://', '/', '.', '?', '&', ',', 'html'), '', $u); return $u; } function cache($c = 3600, $file = NULL) { global $_C; if ($c && !is_numeric($c) && !$file) { $file = $c; $c = 3600; } if (isset($_C['cachedir'])) $this->dir = $_C['cachedir'] . '_curl/'; elseif (defined('ROOT')) $this->dir = ROOT . "_assets/_cache/_curl/"; if (file_exists($this->dir)) { $this->cache = TRUE; if ($file) $this->cache = $file; $this->cache_time = $c; } return $this; } function ssl($ver = FALSE) { curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, FALSE); if ($ver) { curl_setopt($this->ch, CURLOPT_SSLVERSION, $ver); } return $this; } function httpheader($h) { curl_setopt($this->ch, CURLOPT_HTTPHEADER, $h); return $this; } function post($p) { curl_setopt($this->ch, CURLOPT_POST, 1); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $p); return $this; } function cookies($c) { curl_setopt($this->ch, CURLOPT_COOKIEFILE, $c); curl_setopt($this->ch, CURLOPT_COOKIEJAR, $c); return $this; } function referer($u = null) { return $this->ref($u); } function ref($url = null) { if (!$url) $url = $this->url; curl_setopt($this->ch, CURLOPT_REFERER, $url); return $this; } function file($f) { curl_setopt($this->ch, CURLOPT_FILE, $f); return $this; } function get($d) { if (is_array($d)) { $t = ""; foreach ($d as $c=>$v) { if ($t) $t .= "&"; $t .= $c . "=" . $v; } }else $t = $d; curl_setopt($this->ch, CURLOPT_URL, $this->url . '?' . $t); return $this; } function header($h = 1) { curl_setopt($this->ch, CURLOPT_HEADER, $h); if ($h) $this->_header = TRUE; return $this; } function nobody($nb = 1) { curl_setopt($this->ch, CURLOPT_NOBODY, $nb); if ($nb) $this->_nobody = TRUE; return $this; } function exec() { if ($this->cache) { if ($this->cache !== TRUE) $file = $this->cache; else $file = md5($this->url); $a = glob($this->dir . $file . '~*'); foreach ($a as $_a) { list($f, $exp) = explode('~', $_a); if ($exp > date('U')) { $x = file_get_contents($this->dir . $file . '~' . $exp); if ($this->cache_gzip) { $x = gzinflate($x); } return $x; } } } $x = curl_exec($this->ch); $_x = $x; if(curl_exec($this->ch) === false) { echo 'Curl error: ' . curl_error($this->ch); } $this->close(); if ($this->cache && $x) { if ($this->cache !== TRUE) $file = $this->cache; else $file = md5($this->url); $end = (date('U') * 1) + $this->cache_time; $file .= '~' . $end; if ($this->cache_gzip) { $x = gzdeflate($x, 2); } file_put_contents($this->dir . DS . $file, $x); unset($x); // die(); } return $_x; } function close() { curl_close($this->ch); } function info() { return curl_getinfo($this->ch); } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.