Need help to convert this to cURL

software development

#1

Hi all i am new here

I have just found out Dream host wont let this script work

It says i have to change it to cURL but i dont know how to do this.

Any help will be appreciated Thank you
I keep getting a problem with this “file_get_contents” unsure how to change it

This is the script i need to change to curl help please

<?php $clanid="10434"; function startTag($parser, $name, $attrs) { global $stack; $tag=array("name"=>$name,"attrs"=>$attrs); array_push($stack,$tag); } function cdata($parser, $cdata) { global $stack; $stack[count($stack)-1]['cdata'] .= $cdata; } function endTag($parser, $name) { global $stack; $stack[count($stack)-2]['children'][] = $stack[count($stack)-1]; array_pop($stack); } // Parse XML $stack = array(); $claninfo = array(); $clanstats = array(); $playerstats = array(); $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startTag", "endTag"); xml_set_character_data_handler($xml_parser, "cdata"); $xmllink="http://bf2tracker.com/livefeed/xml_clanprofile.php?clanid=$clanid"; $data = xml_parse($xml_parser,file_get_contents($xmllink)); if(!$data) die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); xml_parser_free($xml_parser); // Get Data // Get Clan Profile Data for($i = 0; $i < sizeof($stack[0][children][0][children]); $i ) { $valname=$stack[0][children][0][children][$i][name]; $claninfo[$valname]=$stack[0][children][0][children][$i][cdata]; } // Get Clan Stats Data for($i = 0; $i < sizeof($stack[0][children][1][children]); $i ) { $valname=$stack[0][children][1][children][$i][name]; $clanstats[$valname]=$stack[0][children][1][children][$i][cdata]; } // Get Player Data for($i = 0; $i < sizeof($stack[0][children][2][children]); $i ) { for($x = 0; $x < sizeof($stack[0][children][2][children][$i][children]); $x ) { $valname=$stack[0][children][2][children][$i][children][$x][name]; $value=$stack[0][children][2][children][$i][children][$x][cdata]; if($valname=="PLAYERID") $pid=$value; $playerstats[$pid][$valname]=$value; } } // Now we have 3 arrays with all stats and infos // print_r($claninfo); // print_r($clanstats); // print_r($playerstats); // Display Clan Info echo "Clan Info: \n"; foreach($claninfo as $key => $value) { echo "$key: $value \n"; } // Display Clan Stats echo " Clan Info: \n"; foreach($clanstats as $key => $value) { echo "$key: $value \n"; } // Display Player Stats echo " Player Stats: \n"; foreach($playerstats as $key => $value) { $playername=$playerstats[$key][PLAYERNAME]; $playerurl=$playerstats[$key][PLAYERSTATSURL]; if($playerstats[$key][PLAYERRANK]!="") $playerrank=$playerstats[$key][PLAYERRANK]; else $playerrank=0; if($playerstats[$key][PLAYERSTATUS]=="1") $statuspic="ponline.gif"; else $statuspic="poffline.gif"; echo " $playername "; } ?>

Thank you
Gary Jones


#2

Change this:$xmllink="http://bf2tracker.com/livefeed/xml_clanprofile.php?clanid=$clanid"; $data = xml_parse($xml_parser,file_get_contents($xmllink));To this:$xmllink="http://bf2tracker.com/livefeed/xml_clanprofile.php?clanid=$clanid"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $xmllink); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5); $file_contents = curl_exec($ch); curl_close($ch); $data = xml_parse($xml_parser,$file_contents);--------
si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]