I am following the article/example – artisansweb . net/tweet-twitter-php – to send Tweets via the Twitter API. The code below, or slight variations of it, is what I’m using. This all works very well in localhost. However, when transferred to my hosting site, InfinityFree . net, I get a fatal error in the authentication. I’ve double and triple checked that the reference files, .env keys/tokens & vender/abraham/twitterouath/twitteroauth are there in the same configuration as in my LAMP server. I use the .env file for other APIs without a problem. Transferring to my hosting site infinityfree . net I get this error shown in the image.
`<?php
require_once "vendor/autoload.php";
include('loadenv.php');
use Abraham\TwitterOAuth\TwitterOAuth;
define('CONSUMER_KEY', $_ENV['OAUTH_CONSUMER_KEY']);
define('CONSUMER_SECRET', $_ENV['OAUTH_CONSUMER_KEY_SECRET']);
define('ACCESS_TOKEN', $_ENV['OAUTH_ACCESS_TOKEN']);
define('ACCESS_TOKEN_SECRET', $_ENV['OAUTH_ACCESS_TOKEN_SECRET']);
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$status = 'Check out The Gifted: A Positive Tale of Mutation. ';
$post_tweets = $connection->post("statuses/update", ["status" => $status]);
echo 'Tweet Program Ended';`
Top comments (0)