FuCloud Sam
FuCloud Sam

Reputation: 99

Fatal error: Call to undefined method TwitterOAuth::request()

<?php
session_start();
ini_set('display_errors', '1');

require_once 'twitteroauth.php';

I define my consumer key, consumer secret, oauth key and oauth secret.

define("CONSUMER_KEY", "my consumer key");
define("CONSUMER_SECRET", "my consumer secret");
define("OAUTH_TOKEN", "my oauth token");
define("OAUTH_SECRET", "my oauth secret");

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN,     OAUTH_SECRET);

// https://dev.twitter.com/docs/api/1.1/get/users/show
// Get User details

$user_id = 123456789; // user id can be fetched and stored from step 2.
$user_name = 'xxxx'; // screen name can be fetched and stored from step 2.

$content = $connection->get('account/verify_credentials');

my browser show me => Fatal error: Call to undefined method TwitterOAuth::request() but I could not understand where is the error.

$connection->request('GET', $connection->url('1.1/users/show'), array('screen_name' =>     $user_name));

print '<pre>'; 
$decode_response = json_decode($code);
print_r($decode_response);
// It gives you - id, name, screen name, location, description, url, 
// followers count, following count, latest status, etc.
?>

Upvotes: 0

Views: 1103

Answers (1)

MattRogowski
MattRogowski

Reputation: 866

You're not using the library right.

$connection->request('GET', $connection->url('1.1/users/show'), array('screen_name' => $user_name));

I'm unsure where you got this from. Try:

$connection->get('users/show', array('screen_name' => $user_name));

Upvotes: 1

Related Questions