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?<?php
$cwings="";
$str_in = file_get_contents("http://www.somesite.com/somepage");
$cwings = substr($str_in, 0, 15000);
echo $cwings;
?>
get source of page in another domain
Moderator: General Moderators
get source of page in another domain
i have the code
You will need to send a login cookie with http://www.php.net/curl
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
feyd | Please use
it just returns the login page
feyd | Please use
Code: Select all
andCode: 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 workCode: 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);
?>feyd | Please use
Code: Select all
andCode: 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]