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

curl-and-php

Re: Can't Reconcile Difference Between PHP /w cURL and Unix Command Line cURL

From: Deepesh Malviya <deep0mal_at_gmail.com>
Date: Wed, 10 Jun 2009 08:45:38 +0530

Hi Josh,

I would recommend that you try to capture the result which the curl call
will return to you and additionally use curl_getinfo() function to get more
information about your call. That can provide you exact error message which
might be coming through.

Regards,
Deepesh

On Wed, Jun 10, 2009 at 2:03 AM, Josh Tabak <josh_at_acesadvertising.com>wrote:

> I am trying to use curl to send post data from domain A to a php page on
> domain B which parses the post information and modifies a user database.
>
>
>
> I do not need the html output that curl grabs from the php page on domain B
> (as I want the user to stay on domain A), I only need the database to be
> modified. I would just do this using php and not cURL, but the php page on
> domain B can’t be changed right now, so I can’t get back to domain A if I
> post to domain B.
>
>
>
> I can successfully send a request that correctly modifies the database
> using the unix command curl, but can’t get it to work using php.
>
>
>
> Are there differences in the default settings of the two that could be
> causing this problem?
>
>
>
> Here is my unix command:
>
>
>
> curl 'http://www.domainB.com/signup_submit.php' \
>
> -H 'Host: www.domainB.com' \
>
> -H 'User-Agent: Mozilla/5.0 (windows; U; Windows NT 6.0; en-US; v:1.9.0.10)
> Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)' \
>
> -H 'Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
>
> -H 'Accept-Language: en-us,en;q=0.5' \
>
> -H 'Accept-Encoding: gzip,deflate' \
>
> -H 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' \
>
> -H 'Keep-Alive: 300' \
>
> -H 'Connection: keep-alive' \
>
> -H 'Referer: http://www.domainB.com/page.html' \
>
> -H 'Content-Type: application/x-www-form-urlencoded' \
>
> -H 'Content-Length: 112' \
>
> -d 'email_address=test210_at_mailinator.com&tracker_id=test210&offer_id=997'
> \
>
> -o out.html -D header.txt –L
>
>
>
>
>
> And my php code, which does not result in any database modification:
>
>
>
>
>
> $url = 'http://www.domainB.com/signup_submit.php';
>
> $data = 'email_address=test210_at_mailinator.com
> &tracker_id=test210&offer_id=997';
>
> $ch = curl_init();
>
>
>
> $header[0] = 'Host: www.domainB.com';
>
> $header[] = 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
> rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)';
>
> $header[] = 'Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
>
> $header[] = 'Accept-Language: en-us,en;q=0.5';
>
> $header[] = 'Accept-Encoding: gzip,deflate';
>
> $header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
>
> $header[] = 'Keep-Alive: 300';
>
> $header[] = 'Connection: keep-alive';
>
> $header[] = 'Referer: http://www.domainB.com/page.html';
>
> $header[] = 'Content-Type: application/x-www-form-urlencoded';
>
> $header[] = 'Content-Length: 112';
>
>
>
>
>
> curl_setopt($ch,CURLOPT_URL,$url);
>
> curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);
>
> curl_setopt($ch,CURLOPT_POST,true);
>
> curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
>
> curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
>
> curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
>
>
>
> $result = curl_exec($ch);
>
> curl_close($ch);
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>

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