cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

RE: Curl and Ajax

From: Liu Shan Shui <me_at_lx.sg>
Date: Fri, 15 May 2009 01:16:46 +0800

Hi Cem,

 

You can either parse the HTML form for the form_token value which changes
dynamically and put it in $postdata['form_token'], or generate it by
including the necessary Drigg files and calling drupal_get_token() to
retrieve the form_token value.

 

More info:

http://drupal.org/node/90808

http://api.drupal.org/api/function/drupal_get_token/6

 

With regards,

Liu Shan Shui

me_at_lx.sg

"Life would be much easier if I had the source code." - Anonymous

 

From: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] On Behalf Of Cem S
Sent: Tuesday, May 12, 2009 11:48 PM
To: curl-and-php_at_cool.haxx.se
Subject: RE: Curl and Ajax

 

Hello,

Thank you for quick reply.

Login script ;

<?php
  $cookie_file_path = "/home/xxxxx/public_html/cookie.txt";

        $fp = fopen($cookie_file_path,'wb');
        fclose($fp);

        $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
rv:1.7.12)Gecko/20050915 Firefox/1.0.7";

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,"http://www.xxxxxx.com/user/login");
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
        curl_setopt($ch,
CURLOPT_REFERER,"http://www.xxxxxx.com/user/login");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch,
CURLOPT_POSTFIELDS,"name=admin&pass=adminhere&form_id=user_login&op=Log
in");
        
        $store = curl_exec ($ch); //kaydet
        curl_setopt($ch, CURLOPT_COOKIEFILE,
'/home/xxxxx/public_html/cookie.txt');
        curl_setopt($ch, CURLOPT_URL, "http://www.xxxxxx.com");
        $html = curl_exec($ch);
        echo $html;
?>

Post Script ;

<?php

$postdata=array();
// &form_id=drigg_node_form&op=Submit
$postdata['url']="http://www.domainname.com";
$postdata['title']="title";
$postdata['body']="body paragraph";
$postdata['taxonomy[4]']="32";
$postdata['taxonomy[tags][6]']="test";
$postdata['form_token']="87517a3d7c11c8d8af9f2d2f0142f1a1";
$postdata['form_id']="drigg_node_form";
$postdata['op']="Submit";

$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
rv:1.7.12)Gecko/20050915 Firefox/1.0.7";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.xxx.com/submit");
curl_setopt($ch, CURLOPT_COOKIEFILE, '/home/xxxx/public_html/cookie.txt');

curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);
$buf=curl_exec ($ch);
curl_close ($ch);

echo $buf;

?>

Post script fill the forms correctly and trying to submit it but the
response from my web site is "Validation error, please try again. If this
error persists, please contact the site administrator."

Sincerely,

  _____

Date: Tue, 12 May 2009 16:13:29 +0100
Subject: Re: Curl and Ajax
From: msjunior_at_gmail.com
To: curl-and-php_at_cool.haxx.se

as u said, posting ur script would help us help u

best.

2009/5/12 Cem S <lordofthedreamer_at_live.com>

Hello dear curl-and-php mail list users,

First time, I have joined a maillist, If I do something wrong, please let me
know.

I have problem post something to my web site with curl. I am using drigg on
my web site.

My script can/cannot do following actions ;

Can login to the web site.
Can fill the forms.
Can't submit.

I think, the problem is with drigg. Drigg checks urls valid or not.

Any help would be appreciated. If needed I could post my curl script.

Kind regards,

  _____

check out the rest of the Windows LiveT. More than mail-Windows LiveT goes
way beyond your inbox. More than messages
<http://www.microsoft.com/windows/windowslive/>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

 

  _____

check out the rest of the Windows LiveT. More than mail-Windows LiveT goes
way beyond your inbox. More than
<http://www.microsoft.com/windows/windowslive/> messages

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-05-14