【发布时间】: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