Reputation: 435
I am using the Abraham TwitterOAuth PHP SDK. I included the library at the top of index.php
(File exists + I use <?php
).
<?php
require 'inc/oauth/autoload.php';
var_dump(file_exists('inc/oauth/autoload.php')); //true
use Abraham\TwitterOAuth\TwitterOAuth;
Below, between the HTML I include a .php
file in a div
, like so:
<?php include('div.php'); ?>
In this div.php
file I instantiate the TwitterOAuth class, which throws an error:
if (isset($_COOKIE['token']) && !empty($_COOKIE['token'])) {
$token = objectToArray(json_decode($_COOKIE['token']));
$connection = new TwitterOAuth(CONSUMER, SECRET, $token['oauth_token'], $token['oauth_token_secret']);
This throws the error Class 'TwitterOAuth' not found
.
Note
This was functioning BEFORE I moved the code to div.php
. I however need it to be seperate because in the future I will refresh the div using JQuery.
Upvotes: 0
Views: 686
Reputation: 15629
The class uses the Abraham\TwitterOAuth
namespace - so you have to include them or use the fqn (fully qualified classname)
$connection = new \Abraham\TwitterOAuth\TwitterOAuth(CONSUMER, SECRET, $token['oauth_token'], $token['oauth_token_secret']);
Upvotes: 1