Can't get a basic tweet post example to work
bombarding1 opened this issue · comments
FYI The example code has an error in the credential array, it's missing a comma. Unless it's implied to remove it if you aren't using auth 2.0, which I did.
I can't get a basic tweet creation example to work:
<?php
require_once 'vendor/autoload.php';
use Coderjerk\BirdElephant\BirdElephant;
//your credentials, should be passed in via $_ENV or similar, don't hardcode.
$credentials = array(
'consumer_key' => '', //valid confirmed through CURL
'consumer_secret' => '', //valid confirmed through CURL
'bearer_token' => '', //valid confirmed through CURL
'token_identifier' => '', //valid confirmed through CURL
'token_secret' => '' //valid confirmed through CURL
);
//instantiate the object
$twitter = new BirdElephant($credentials);
$tweet = (new \Coderjerk\BirdElephant\Compose\Tweet)->text("test tweet");
$twitter->tweets()->tweet($tweet);
?>
Results in the error:
PHP Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST) in /var/www/vendor/coderjerk/bird-elephant/src/BirdElephant.php on line 21
Any ideas? Thank you.
I resolved it by adding editing the app and adding it to my project. It appears that the project is added visually but it's not until you actually edit the app and link it to your project. Error has now seemed to go away. I'll close this now.