J7mbo / twitter-api-php

The simplest PHP Wrapper for Twitter API v1.1 calls
MIT License
1.82k stars 802 forks source link

How can I get Exception issue ? #282

Open pascal37stage opened 5 years ago

pascal37stage commented 5 years ago

Hello, I would like to know if it is possible to get an Exception from a try catch for my Twitter API ? Indeed when I have some issue from acces token or consumer_key I don't get any Exception from the API in order to explain me why it doesn't work and where to find the problem.

Here is the code : $requestMethod = "GET";

$settings = array(
    'oauth_access_token' => $config['access_token'],
    'oauth_access_token_secret' => $config['access_token_secret'],

    'consumer_key' => $config['consumer_key'],
    'consumer_secret' => $config['consumer_secret']
);

$getfield = '?screen_name=' . $config['name'] . '&count=20&tweet_mode=extended';
try{ 
$twitter = new TwitterAPIExchange($settings);

$resultat = $twitter->setGetfield($getfield)

    ->buildOauth($url, $requestMethod)
    ->performRequest();

$data = json_decode($resultat);
}
catch (Exception $e)
{
   echo 'Twitter API return an error '.$e->getMessage();
   exit;
}