I am trying to get content from the page below. For my own purpose, i am just interested on the tag so then i could put it into an array for when i send the bot response back to Twitter API with their appropriate method. Here's what i tried:
<?xml version="1.0" encoding="ISO-8859-1"?>
<conversation convo_id="$convo_id">
<bot_name>infobot2012</bot_name>
<user_name>User</user_name>
<user_id value='2' />
<usersay>$say</usersay>
<botsay>Internal error detected. Please inform my botmaster. </botsay>
</conversation>
$url = "http://localhost/Program-O/chatbot/conversation_start.php?say=$say&
hello&convo_id=$convo_id&bot_id=$bot_id&format=xml";
get_url_contents($url)
$crl = curl_init(); //getting Parse error: syntax error, unexpected T_VARIABLE
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
You're missing a semi-colon on the line above it:
get_url_contents($url)
should be
get_url_contents($url);
Try this:
function get_url_contents($url) {
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
$url = "http://localhost/Program-O/chatbot/conversation_start.php?say=" . $say . "&hello&convo_id=" . $convo_id . "&bot_id=" . $bot_id . "&format=xml";
echo get_url_contents ($url);