【问题标题】:Fatal error: Call to undefined method TwitterOAuth::request()致命错误:调用未定义的方法 TwitterOAuth::request()
【发布时间】:2014-08-12 19:09:46
【问题描述】:
<?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');

我的浏览器显示 => 致命错误:调用未定义的方法 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.
?>

【问题讨论】:

    标签: twitter twitter-oauth


    【解决方案1】:

    你没有正确使用图书馆。

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

    我不确定你是从哪里得到的。试试:

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

    【讨论】:

      猜你喜欢
      • 2015-11-11
      • 1970-01-01
      • 2016-05-16
      • 2015-01-28
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多