Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   cURL (http://www.greenguysboard.com/board/showthread.php?t=34984)

Xallow 2006-10-03 07:48 AM

cURL
 
Hi guys and gals

Apparently my host uses cURL, I dont have a clue how to use this and I really need to use it for some xml feeds, I would be deeply in your debt if You could help me... I need file you can download here to work with it... dont worry.. its not a virus or trojan or anything, I like being at GG&J and wouldn't want to be banned.

http://www.netcamperformers.com/perflister.zip

satan tried to explain it to me in another thread and I looked it up in some php books but the books I have said nothing of cURL.

Thanks for Your help

Xallow

kitty_kate 2006-10-03 07:59 AM

In your script, I see at the line number 36 this:
PHP Code:

$xml_content file_get_contents$xml_source 

Here is where you have to make the change.

Add this function to your script, at the beggining of it, right after the tag line:

PHP Code:

/**
  * Retrieves the url
  *
  * @param string $url
  * @param string $uagent
  * @return string
  */
 
function retrieveUrl($url) {
     
// create a new CURL resource
     
$ch curl_init();
     
// set URL and other appropriate options
     
curl_setopt($chCURLOPT_URL$url);
     
curl_setopt($chCURLOPT_HEADERtrue);
     
curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
     
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
     
// grab URL and pass it to the browser
     
$result curl_exec($ch);
     
// close CURL resource, and free up system resources
     
curl_close($ch);     
     return 
$result;
 } 

Then change your code at the 36th line into:
PHP Code:

$xml_content retrieveUrl$xml_source 

I didn't tested it 'cause I'm on the run, but it should work.

Xallow 2006-10-03 08:23 AM

That took care of the error, but it still doesnt show the content

kitty_kate 2006-10-03 09:41 AM

Hang on there, I'm looking into it right now

kitty_kate 2006-10-03 09:51 AM

Ok, my bad. My function is returning the HTTP headers with the content, and that was making the XML parser to give an error. You have to return to the function I gave you and change a parameter inside it.

PHP Code:

curl_setopt($chCURLOPT_HEADERtrue); 

must become

PHP Code:

curl_setopt($chCURLOPT_HEADERfalse); 

This way it will work.

Xallow 2006-10-03 10:27 AM

That did it, thanks a bunch Kitty Kate

kitty_kate 2006-10-03 10:51 AM

No problem, tiger. Glad I could help you |thumb


All times are GMT -4. The time now is 01:25 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc