php - Fatal Error: Call to undefined function curl() -
this code below twiiter app. tried rectify error no avail
fatal error: call undefined function curl() in c:\wamp\www\tweet\twitter.php on line 47
what have edit in code?
<?php require_once('twitterapiexchange.php'); $settings = array( 'oauth_access_token' => "", 'oauth_access_token_secret' => "", 'consumer_key' => "", 'consumer_secret' => "" ); $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; $requestmethod = "get"; if (isset($_get['user'])) {$user = $_get['user'];} else {$user = "iagdotme";} if (isset($_get['count'])) {$user = $_get['count'];} else {$count = 20;} $getfield = "?screen_name=$user&count=$count"; $twitter = new twitterapiexchange($settings); $string = json_decode($twitter->setgetfield($getfield) ->buildoauth($url, $requestmethod) ->performrequest(),$assoc = true); if (is_array($string)) { foreach($string $items) { echo "time , date of tweet: ".$items['created_at']."<br />"; echo "tweet: ". $items['text']."<br />"; echo "tweeted by: ". $items['user']['name']."<br />"; echo "screen name: ". $items['user']['screen_name']."<br />"; echo "followers: ". $items['user']['followers_count']."<br />"; echo "friends: ". $items['user']['friends_count']."<br />"; echo "listed: ". $items['user']['listed_count']."<br /><hr />"; } } $api = "http://api.twitter.com/1/users/show.xml?screen_name="; $users = file("users.txt", file_ignore_new_lines); $i = 0; if (is_array($users)) { foreach($users $user) { $data = curl("$api$user"); preg_match("#<description>(.*?)</description>#is", $data, $matches); $bio[$i]["user"] = $user; $bio[$i]["description"] = $matches[1]; $i++; } function curl($url) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_close($ch); return curl_exec($ch); } }
move declaration of curl()
function outside if(){}
block contains it, this.
if (is_array($users)) { foreach($users $user) { $data = curl("$api$user"); preg_match("#<description>(.*?)</description>#is", $data, $matches); $bio[$i]["user"] = $user; $bio[$i]["description"] = $matches[1]; $i++; } } function curl($url) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); $result = curl_exec($ch); curl_close($ch); return $result; }
Comments
Post a Comment