Php curl


#1

Ok since Dreamhost doesn’t allow these regular type php includes (for my plan atleast) I found out I had to use php url.

I keep trying to get it to work but I keep getting a system error.
Example: http://xposure.nu is a rotation site that gives you a basic include but I can’t figure out how to make it into php curl in which it will work and I don’t get an error.

any idea?


#2

Try searching the forums/wiki for compiling PHP.
Are you including it so it displays something?

I think it would be something like:

[quote]<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “http://example.com/”);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?> [/quote]

We’re [color=#0000CC]DreamingOfYou[/color] :wink: Use PromoCode PerfectDream to save you the most?


#3

I did… I’ve tried that specific one already. It gave me an error then just didn’t work. I make my site in wordpress. Php is allowed there.

I searched the forums & wiki. Thats why I’m asking. But yea it shows a rotation. It shows random comment links…


#4

Please post the specific piece of code that isn’t working (the original code). We can take a look at the code and see how to adapt it to work with cURL.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#5

heres the code I need into php curl:

<?php include("http://www.xposure.nu/code.php?uid=33"); ?>

#6

Can you not just do it like this?

<?php $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, 'http://www.xposure.nu/code.php?uid=33'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); echo $file_contents; ?>It is functionally equivalent to this:

<?php include("http://www.xposure.nu/code.php?uid=33"); ?>--------
Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#7

I make my pages in wordpress and when I do it I get

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

It happens everytime I paste that code in. I’ve tried it. When I take it out I can edit fine.


#8

[quote]I make my pages in wordpress and when I do it I get

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

It happens everytime I paste that code in. I’ve tried it. When I take it out I can edit fine.[/quote]
Well there is nothing wrong with the code I gave you. I just tried running it, inserting it on a blank page between to


elements, and it works fine. You can see it here: http://jessey.net/tests/toyomo.php. Maybe their server really was down at the time you tried it?

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#9

Thanks! I’ll just add it without wordpress. The server isn’t down its just a wordpress 503 error. As long as the codes not there I can use it fine but when it is I can’t.

Stupid wordpress. Thanks a lot :slight_smile:


#10

You could also write it like a function, so that you can use the cURL-type include all the time:

[code]<?php
function url_include($url) {
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}

$include = url_include(“http://www.xposure.nu/code.php?uid=33”);
print $include;
?>[/code]--------
Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#11

Simon,
A quick question. Do you know of any sites or books that go into detail on how curl works like what each option does with sample code?
The php manual tells some but I feel it is lacking.
Silk


#12

The only major source I know of is the documentation: http://curl.haxx.se/docs/


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#13

Thanks,
Silk


#14

How do you get wordpress to allow php curl? so that everytime I add a curl include I don’t have to dowload the file. I don’t mind doing it but when you have pages in wordpress I don’t think you can download those.

Just wondering is it possible to make wordpress allow it w/out a 503 error?