Jump to content

Login to on one page and then get another page Help!


Recommended Posts

Hey guys I am new here, I am trying to Get from my Api,Im using curl in php to log into on one page and

then get another page passing all cookies from the first page along with you but I keep getting Access denied!!

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookieFileName");
curl_setopt($ch, CURLOPT_URL,"http://www.supersaas.com/api/users");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "?account=myname&password=mypassword");

ob_start();      // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean();  // stop preventing output

curl_close ($ch);

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookieFileName");
curl_setopt($ch, CURLOPT_URL,"http://www.supersaas.com/api/users?id=12");

$buf2 = curl_exec ($ch);

curl_close ($ch);

echo "<PRE>".htmlentities($buf2);

What's wrong with the code????

Link to comment
Share on other sites

Double check the name and value attributes and their values. This works for me -> 



curl --cookie-jar cjar --output /dev/null 'http://www.supersaas.com'

curl --cookie cjar --cookie-jar cjar --data 'name='${NAME} --data 'password='${PASS} --data 'remember='${REMEMBER} --location \

Edited by jazzman1
Link to comment
Share on other sites

Post the source code of this html form of the second page.

This is my source code..


I can log in and pull the data manually, but it doesnt work with the code.. now when I log in to the first page it return xml file I use this url (http://www.supersaas.com/api/users?account=myname&password=mypassword)


, than I try to run a filler in order the get user id  that I need (  curl_setopt($ch, CURLOPT_URL,"http://www.supersaas.com/api/users?id=12"); )


than I am getting " HTTP Basic: Access denied. ", 


I hope it clear now, THANKS A LOT 

Link to comment
Share on other sites

Works for me.



curl --cookie-jar cjar --output /dev/null 'http://www.supersaas.com'

curl --cookie cjar --cookie-jar cjar --location \




[jazz@centos-box ~]$ ./curl
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14530  100 14530    0     0  44949      0 --:--:-- --:--:-- --:--:-- 67897

<?xml version="1.0" encoding="UTF-8"?>
<nil-classes type="array"/>

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.

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.