PDA

View Full Version : How do I install cURL on my host?



zoobie
August 27th, 2002, 04:02
I can't seem to find how to install cURL on my virtual host. Anyone know how?

And then, I want to post to a http...Does this require an include? And do I just make a regular form 'submit' button?

I'm using PHP.

Thanks :rolleyes:

Salam
August 28th, 2002, 06:25
The home page is here (http://curl.haxx.se/) .
See the manual (http://www.php.net/manual/en/ref.curl.php) for installation .

If you want let users to "POST" , just make a <form ... method=post> .
But if you want "POST" from your PHP script try fsockopen() .
Attachment file is a simple connection util .

zoobie
August 30th, 2002, 03:56
I don't see --with-curl in my hosts info.php page. This is why I'm wondering if I can just install it within a folder on my host and run a script. I need to post to a http(s) and don't want to use the regular "method=post action=next.php" :D

ProQ
August 30th, 2002, 04:13
you cant do that

Salam
August 30th, 2002, 15:35
I am not sure, but dl() may help you to load curl dynamically .
But if you just want to "POST", you dont need curl .
Use fsockopen() and network functions (http://www.php.net/manual/en/ref.network.php) .

zoobie
August 31st, 2002, 03:14
I've tried 3 fsockopen() scripts including Zend's and they're all broken. :confused2

I found one @hotscripts...I think it's posting my encoded form data (I get no errors)...but I need to go to the site where it's been posted. All I'm getting is a blank page.

I don't get it. ogre2

Salam
August 31st, 2002, 06:51
Originally posted by zoobie
I've tried 3 fsockopen() scripts including Zend's and they're all broken. :confused2

Isn't there one script that will post my encoded form data? Jeez...ogre2

<?php
$fp = fsockopen ("www.paypal.com", 80, $errno, $errstr, 90);
if (!$fp) echo "$errstr ($errno)<br>\n";
else {
fputs ($fp, "
POST /cgi-bin/webscr HTTP/1.1
Host: www.paypal.com
Content-Length: 23
Content-Type: application/x-www-form-urlencoded
Connection: Close

cmd=p/ema/index-outside

");
while (!feof($fp)) echo fgets ($fp,128);
fclose ($fp);
}
?>

zoobie
August 31st, 2002, 14:03
Nothing...All I'm getting for the whole page is:

()

I'm assuming the encoded data goes where the "cmd=" is and the length is the data length counting every character.

I tried http://www.paypal.com... Nothing.

Obviously, fsockopen isn't going to work with this site. ogre2

Salam
September 1st, 2002, 07:09
So , try readfile("http://www.paypal.com/cgi-bin/webscr?data") ;
This use "GET" method but your users will not see the url .
Also you are not redirected to the site, but the data will be sent back to your page .

zoobie
September 1st, 2002, 12:40
Wait a sec...My host has disabled popen, fsockopen, & pfsockpen. I switched hosts.

Ok! I got it working with another script which cuts off the headers. Now, the problem is the result is just plain default text. I need to know how to include Paypal's stylesheet. I know the address is http://www.paypal.com/css/pp_styles_082102.css ...but I can't seem to trigger it so it displays with the style. I've tried include ("http://www.paypal.com/css/pp_styles_082102.css");

Where would I put their style sheets below to get the page to display properly?

<?php

include('./class.HTTPPost.inc');

$arr['cmd'] = '_xclick';
$arr['business'] = 'me@softhome.net';
$arr['item_name'] = 'Custom Wav';
$arr['amount'] = '4.95';
$arr['no_shipping'] = '1';
$arr['cancel_return'] = 'members.lycos.co.uk%20zoobie%20finish2.php';
$arr['no_note'] = '1';
$arr['no_shipping'] = '1';

$post = new HTTPPost('http://www.paypal.com/cgi-bin/websrc', $arr);
$result = $post->post();

if($headers){
print nl2br($post->getResponseHeaders());
}

print $result;

/* equivalent to:
print $post->getResponseBody();
*/


?>

Salam
September 2nd, 2002, 14:21
This may help :
add :
echo "<style type=text/css>" ;
include('http://www.paypal.com/css/pp_styles_082102.css ') ;
echo "</style>" ;
before print $result; .

Note that <style ...> must be in <head> ... </head> , so if the above code dosnt work try this :

$str="<style type=text/css>".file_get_contents('http://www.paypal.com/css/pp_styles_082102.css ') ."</style>";
$result = str_replace("<head>", "<head>$str", $result);
// or <HEAD>

zoobie
September 2nd, 2002, 14:39
I got it to display using preg_replace...but I'm going to scrap this whole thing.

I need it to get/post to httpS (ssl)...and I can't use cURL or find any scripts in php.

Thanks :cry2:

Salam
September 4th, 2002, 15:23
PHP 4.3.0 (+OpenSSL) supports ssl:// . You can wait until your provider upgrade to 4.3.0 (if has OpenSSL).

But you can use curl too :
For GET :
<?php
$ch = curl_init("https://www.paypal.com/cgi-bin/webscr?cmd=p/ema/index-outside") ;
curl_exec ($ch);
curl_close ($ch);
?>

And for POST :
<?php
$ch = curl_init("https://www.paypal.com/cgi-bin/webscr") ;
curl_setopt ($ch, CURLOPT_POST, 1) ;
curl_setopt ($ch, CURLOPT_POSTFIELDS, "cmd=p/ema/index-outside") ;
curl_exec ($ch);
curl_close ($ch);
?>

If you want a free host + curl support try selfmaster.de (http://www.net-soft.de/webspace.html) .

zoobie
September 5th, 2002, 23:58
I'll check it out...Thanks:cool: