致命错误:调用未定义的方法TwitterOAuth :: request()

时间:2014-08-10 19:19:07

标签: twitter twitter-oauth

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

require_once 'twitteroauth.php';

我定义了我的消费者密钥,消费者秘密,oauth密钥和oauth秘密。

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');

我的浏览器显示我=&gt;致命错误:调用未定义的方法TwitterOAuth :: request() 但我无法理解错误在哪里。

$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.
?>

1 个答案:

答案 0 :(得分:1)

你没有正确使用图书馆。

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

我不确定你从哪里得到这个。尝试:

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