Jump to content

Curl Login and IFrames


SidewinderX

Recommended Posts

Ive created a script to login to a site which works fine, but when I login, that site has an iframe I want to grab data from. The problem is the iframe displays a 404 error because the file it is looking for is account.php which is not on my server, but the server i am logging into.

 

Using my script, how can I get access to the file thats in the iframe?

 

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/");
curl_setopt($ch, CURLOPT_COOKIEFILE, "C:/");

curl_setopt($ch, CURLOPT_URL, $host."/myaccount.php?");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "login_username=".$username."&login_password=".$password."");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_exec($ch);
curl_close ($ch);


?> 

Link to comment
https://forums.phpfreaks.com/topic/42463-curl-login-and-iframes/
Share on other sites

The PHP won't look for anything on your local server. cURL is a browser and browses to the url like you would in Firefox.

 

The only stuff you'd download is HTML and JS.

 

The iFrame will load a web page like a normal frame. So look for the URL it is loading and grab that.

 

monk.e.boy

$ch = curl_init();

curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/");
curl_setopt($ch, CURLOPT_COOKIEFILE, "C:/");

curl_setopt($ch, CURLOPT_URL,$host."myaccount.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "login_username=".$username."&login_password=".$password."");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_exec($ch);
$fp = fopen($host."accounts.php?ac_serverid=4", "r");
curl_close ($ch);
fclose($fp);
echo $fp;

 

Yields:

Resource id #4

 

Not exactly what im looking for  ???

READ THE CURL DOCUMENTATION:

 

http://uk.php.net/curl

 

 

<?php
$pageurl = $host."myaccount.php"
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $pageurl );
$html = curl_exec ( $ch );
curl_close($ch);

$pageurl = $host."accounts.php?ac_serverid=4";
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $pageurl );
$html2 = curl_exec ( $ch );
curl_close($ch);
?>

 

 

monk.e.boy

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.