Results 1 to 10 of 11
Hybrid View
-
1st Aug 2010, 10:59 AM #1OPMemberWebsite's:
oxioServices.com teamOxio.com blackOxio.comProblem using CURL
Hiya all,
I'm trying to use cURL to submit a form on a site (http://ipower.com) and then save the cookie given by the site.
The exact url being: https://secure.ipower.com/secure/login.bml?err=
Can anyone guide me how can i do that ?black0xio Reviewed by black0xio on . Problem using CURL Hiya all, I'm trying to use cURL to submit a form on a site (http://ipower.com) and then save the cookie given by the site. The exact url being: https://secure.ipower.com/secure/login.bml?err= Can anyone guide me how can i do that ? Rating: 5
-
1st Aug 2010, 11:05 AM #2Member
use this to save cookies to a local file.
PHP Code:curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_save_cookie);
Coding Horror Fan
I don't read PM's frequently .
-
1st Aug 2010, 11:07 AM #3MemberWebsite's:
wscripts.net damnlolscript.com lulzjet.comtry this:
function get_web_page( $url )
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => true, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 60, // timeout on connect
CURLOPT_TIMEOUT => 30, // timeout on response
CURLOPT_MAXREDIRS => 5, // stop after 10 redirects
CURLOPT_COOKIEFILE => dirname(__FILE__) . "/cookies.txt",
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
return $header;
}
-
1st Aug 2010, 11:07 AM #4OPMemberWebsite's:
oxioServices.com teamOxio.com blackOxio.com@desiboy: Already tried that but no success.
-
1st Aug 2010, 11:13 AM #5OPMemberWebsite's:
oxioServices.com teamOxio.com blackOxio.comguys whenever i try submitting the form on ipower.com the curl fails to connect , i mean it doesnt connects to ipower.com but instead connects to my localhost.
Here are the headers i get :
Code:http://127.0.0.1/curl2.php GET /curl2.php HTTP/1.1 Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive HTTP/1.1 200 OK Date: Sun, 01 Aug 2010 11:10:25 GMT Server: Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0 X-Powered-By: PHP/5.3.0 Content-Length: 0 Keep-Alive: timeout=5, max=98 Connection: Keep-Alive Content-Type: text/html ---------------------------------------------------------- http://127.0.0.1/favicon.ico GET /favicon.ico HTTP/1.1 Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive HTTP/1.1 404 Not Found Date: Sun, 01 Aug 2010 11:10:28 GMT Server: Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0 Vary: accept-language,accept-charset Accept-Ranges: bytes Keep-Alive: timeout=5, max=97 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 Content-Language: en
-
1st Aug 2010, 11:21 AM #6Member
PHP Code:<?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://secure.ipower.com/secure/login.bml?err=");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$things = array(
'credential_0' => 'desi',
'credential_1' => 'mypass'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $things);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
$output = curl_exec($ch);
curl_close($ch);
?>Coding Horror Fan
I don't read PM's frequently .
-
1st Aug 2010, 11:31 AM #7OPMemberWebsite's:
oxioServices.com teamOxio.com blackOxio.comThank you all at last i got it working.
Thanks to t3odor for his function. the full code is as follows in case any1 needs it
Had to edit some parts though but you got my mind working
Code:<?php function get_web_page( $url ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => true, // don't return headers CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 60, // timeout on connect CURLOPT_TIMEOUT => 30, // timeout on response CURLOPT_MAXREDIRS => 5, // stop after 10 redirects CURLOPT_SSL_VERIFYPEER => false, CURLOPT_COOKIEJAR => dirname(__FILE__) . "\cookie1.txt", CURLOPT_POST => true, CURLOPT_POSTFIELDS => "MY POST DATA HERE FOR LOGIN :)" ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } //end of fn function mailbox( $url ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => true, // don't return headers CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 60, // timeout on connect CURLOPT_TIMEOUT => 30, // timeout on response CURLOPT_MAXREDIRS => 5, // stop after 10 redirects CURLOPT_SSL_VERIFYPEER => false, CURLOPT_COOKIEFILE => dirname(__FILE__) . "\cookie1.txt", CURLOPT_POST => true, CURLOPT_POSTFIELDS => "POST DATA FOR CREATING NEW MAIL BOX HERE" ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } //end of fn get_web_page("https://secure.ipower.com/secureLogin"); mailbox("http://members.ipower.com/webControl/emailpack/mailcentral.bml"); ?>
-
1st Aug 2010, 11:34 AM #8OPMemberWebsite's:
oxioServices.com teamOxio.com blackOxio.com@desiboy: I saw your code a bit late otherwise it would have saved me some time
-
2nd Aug 2010, 10:48 PM #9Member
When using cookies/sessions make sure the file has write acces
-
3rd Aug 2010, 12:56 AM #10MemberWebsite's:
mirrormaker.org
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[Help] PHP Curl Lumfile.com Problem
By heppinnz in forum Web Development AreaReplies: 4Last Post: 23rd Jun 2012, 02:21 PM -
PHP CURL Problem with Pixhost.org
By heppinnz in forum Web Development AreaReplies: 6Last Post: 20th Jun 2012, 05:10 PM -
[Help] PHP Curl Uploader to RapidShare Problem
By heppinnz in forum Web Development AreaReplies: 2Last Post: 29th Nov 2011, 06:28 AM -
curl problem
By cyberz in forum Technical Help Desk SupportReplies: 5Last Post: 6th Aug 2010, 09:05 PM -
cURL or PHP Problem.
By deelow66 in forum Technical and Security TutorialsReplies: 4Last Post: 2nd May 2010, 01:57 AM
themaManager - edit and manage...
Version 4.21 released. Open older version (or...