Jump to content

cURL help


smatts

Recommended Posts

Ok I am trying to login to my Wordpress site from another site using cURL. I am new to cURL and can not understand why this is not working:

 

<?php
   $postData = array();

  $postData['log'] = "username";
  $postData['pwd'] = "blahblah";
  $postData['submit'] = "submit";

   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, "http://www.wordpress.com/wp-login.php" );
   curl_setopt($ch, CURLOPT_COOKIEJAR, cookie.txt);       
   curl_setopt($ch, CURLOPT_COOKIEFILE, cookie.txt);   
   curl_setopt($ch, CURLOPT_POST, 1 );
   curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   $postResult = curl_exec($ch);

   if (curl_errno($ch)) {
       print curl_error($ch);
   }
   curl_close($ch);

?>

 

I want it to fill out the form and submit it so I am logged in. Also with the cookie files, do I need to make one or where should I be pointing those to? Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/37900-curl-help/
Share on other sites

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.