danieldevine/bird-elephant

I wanted to use the tool but I have an error

dzGeekyGirl opened this issue · 1 comments

Describe the bug
Parse error: syntax error, unexpected '/', expecting ';' or ',

To Reproduce
Steps to reproduce the behavior:
I install the tool using the
composer require coderjerk/bird-elephant
I wanted to try the exemple
`use Coderjerk/BirdElephant/BirdElephant;

//your credentials, should be passed in via $_ENV or similar, don't hardcode.
$credentials = array(
'bearer_token' => xxxxxx,
'consumer_key' => xxxxxx,
'consumer_secret' => xxxxxx,
'token_identifier' => xxxxxx,
'token_secret' => xxxxxx,
);

//instantiate the object
$twitter = new BirdElephant($credentials);

//get a user's followers using the handy helper methods
$followers = $twitter->user('coderjerk')->followers();

//pass your query params to the methods directly
$following = $twitter->user('coderjerk')->following([
'max_results' => 20,
'user.fields' => 'profile_image_url'
]);

// You can also use the sub classes / methods directly if you like:
$user = new UserLookup($credentials);
$user = $user->getSingleUserByID('2244994945', null);I changed what should be change with my own bearer_token, secret keys .... But when I try the script I have this error message Parse error: syntax error, unexpected '/', expecting ';' or ', it's in the first ligne meaning that it at the level of theuse `keyword.

Expected behavior
That the script show me the followrs in json

Environment (please complete the following information):

  • windows 10
  • 7.4.2
  • last version got it with composer install

Additional context
I am noobs, I am prety sure I did somthing wrong and I am sorry to bother you but really need some help

Hi @dzGeekyGirl,

Hard to know without seeing your code exactly, but try the below and let me know the result you get.

use Coderjerk/BirdElephant/BirdElephant;

$credentials = array(
'bearer_token' => xxxxxx,
'consumer_key' => xxxxxx,
'consumer_secret' => xxxxxx,
'token_identifier' => xxxxxx,
'token_secret' => xxxxxx,
);

$twitter = new BirdElephant($credentials);

try {
    $followers = $twitter->user('coderjerk')->followers();
} catch (Exception $e) {
    var_dump($e->getResponse()->getBody()->getContents());
}

if ($followers) :
    foreach ($followers->data as $follower) :
        echo "<h3>" . $follower->name . "</h3>";
    endforeach;
endif;