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
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

Link to comment
Share on other sites

$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  ???

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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