Page 1 of 1
get source of page in another domain
Posted: Sun Jan 29, 2006 11:02 pm
by cwings
i have the code
for somesite.com/somepage i want to be able to echo the value of the page for when your logged in, otherwise it just echos the signin page for the site. is there a way to make it get the source of a page that your logged into and with your own session and echo it back?
Posted: Sun Jan 29, 2006 11:06 pm
by josh
You will need to send a login cookie with
http://www.php.net/curl
Posted: Sun Jan 29, 2006 11:12 pm
by cwings
but is there a way to echo it if your already logged into somesite.com without having to relogin with a new cookie?
like getting it from a current session
Posted: Sun Jan 29, 2006 11:54 pm
by josh
The reason that page sees you as logged in is because of the session cookie. If you do not send a cookie that page will not see you as logged in
Posted: Mon Jan 30, 2006 12:29 am
by cwings
could i make a temporary session cookie?
Posted: Mon Jan 30, 2006 12:42 am
by josh
log into the site from your browser, grab the cookie with javascript:alert(document.cookie);
This is the cookie you want to send with CURL
Posted: Mon Jan 30, 2006 2:53 am
by onion2k
cwings wrote:could i make a temporary session cookie?
All session cookies are temporary.
Posted: Mon Jan 30, 2006 9:56 am
by John Cartwright
onion2k wrote:cwings wrote:could i make a temporary session cookie?
All session cookies are temporary.
Unless appended to the url

Posted: Mon Jan 30, 2006 10:55 am
by onion2k
Jcart wrote:onion2k wrote:cwings wrote:could i make a temporary session cookie?
All session cookies are temporary.
Unless appended to the url

Is that a session cookie, or is it a session ID?
Posted: Mon Jan 30, 2006 12:13 pm
by cwings
feyd | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
can you tell me why this doesnt work
Code: Select all
<?php
$id = "username";
$pw = "password";
$postfields = "username=$id&password=$pw";
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "/temp/cookie");
curl_setopt($ch, CURLOPT_COOKIE, "/temp/cookie");
curl_setopt($ch, CURLOPT_URL,
"http://somesite.com/login.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$postfields");
$cwings="";
$filename = curl_setopt($ch, CURLOPT_URL, "http://somesite.com/page_that_can_only_be_seen_if_logged_in");
$str_in = file_get_contents($filename);
$cwings = substr($str_in, 0, 50000);
echo $tween;
curl_exec ($ch);
curl_close ($ch);
?>
it just returns the login page
feyd | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Mon Jan 30, 2006 1:16 pm
by cwings
nevermind, i figured it out. thanks for your help though