cURL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

cURL

Post by ol4pr0 »

Now ihave been a bit busy with the cUrl.
Nice got almost everything to work.

However what i am confused about is the following
curl opens a page (any page)
page executes whatever it needs to execute
and returns a var or whatever.
curl page receives this return

Now that return and receiving that return is what i am missing. How to do that :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Tell cURL you want the return data?

curl_setopt() has the option.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

$result = curl_exec($ch);
echo $result;
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Thanks ill try..

thing is dont have i-net at home.. yea i know 3th world <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>..
so trying to figure out as much as i can howeve get stuck sometimes
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Download the manual to a thumb-drive or CD and bring it home.

http://php.net/download-docs.php
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

:)

Post by ol4pr0 »

jeje. funny guy, do you have any idaea how long it takes me loading up this page.
takes me about 3 minuuts i think. imagen wat a 2mb docs wil do.. takes me sometime and about 10 $USD.

Anyway.

i was messing with the $result = and some other options.
But i keep on getting 1 as return even when i put in a fake url

A short example ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

CURLOPT_RETURNTRANSFER

details are just about this link.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

i believe that i did do that

now i dont have the code with me but it goes simplified like this

$c = curl_init(url)
curl_setopt($c,RETURNTRANSFER,1)
curl_exec($c)
curl_close($c)

Now while tryihng this it didnt reallymather where i put the $result everything echoes 1
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

curl_exec will return the output
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Ok just want to make sure.. here

the page retrieved by cURL.

when i echo something out it does return. but when i use return 1; for example it doesnt return anything.
is this correct or am i doing something wrong here.

Other thing

If i would use like define variables on the other end. would these be accesable when somebody uses cURL to fetch a page from my website for example.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

ol4pr0 wrote:when i echo something out it does return. but when i use return 1; for example it doesnt return anything.
is this correct or am i doing something wrong here.

Code: Select all

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
If CURLOPT_RETURNTRANSFER is set to 1, then it will return it's value ($data will contain the result). If it is not set then it will be outputted.
ol4pr0 wrote: Other thing

If i would use like define variables on the other end. would these be accesable when somebody uses cURL to fetch a page from my website for example.
No, only the html output.
Post Reply