thanks !
In php, I would like to know if a twitter user exist.
For that, I try to recover the content of the url :
$json = file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=".$_GET['search']);
$jsonObject = json_decode($json);
Where $_GET[‘search’] = is the name of the user passed in the URL.
But the problem is that if someone give a username which don’t exist I got an error.
On php.net, they say that file_get_contents return false if there is an error.
I tried to do in a condition :
if(file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=".$_GET['search']) != false){
// do my stuff
}
else{
// say that this username don't exists
}
But when I try this code, I got a big orange warning code which says :
Warning: file_get_contents(http://api.twitter.com/1/statuses/user_timeline.json?screen_name=A_Wrong_User_Name) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP
So I could I remove the error and just check if the twitter user exists or not.
I he exists, I want to get the content of the page with file_get_contents, if not, I want to display that the user doesn’t exist.
Thanks for help !
You should use CURL instead of
file_get_contents: