繁体   English   中英

尝试使用Abraham Williams Twitter API库完全陷入困境

[英]Completely stuck trying to use Abraham Williams Twitter API libraries

我正在通过Sam的Teach Yourself Twitter API进行工作。在第8小时中,有简单的说明来设置消费者密钥,消费者秘密(我已经成功地使用它们使用了另一个php程序)和使用Abraham Williams库。 我将密钥,秘密插入config.php,使用define('OAUTH_CALLBACK','http://localhost/callback.php'); 使用localhost并为其创建了一个tinyurl(如果localhost不起作用,请变通。获得登录Twitter屏幕的信息,然后转到显示以下内容的重定向页面:

“无法连接到Twitter。 刷新页面或稍后重试。”

我完全死在这里的水中。 一旦开始工作,我就可以运行了,但我完全被卡住了。 任何帮助,将不胜感激。

(针对您的问题:)

他们有一个config.php文件,他们说要在其中放入KEY和SECRET,我已经完成了:

define('CONSUMER_KEY', 'KEY');
define('CONSUMER_SECRET', 'SECRET');
define('OAUTH_CALLBACK', 'http://localhost:8888/abeoauth/connect.php');

他们预定运行index.php。 这是以下代码:

/* Load required lib files. */
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');

/* If access tokens are not available redirect to connect page. */
if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) ||     empty($_SESSION['access_token']['oauth_token_secret'])) {
    header('Location: ./clearsessions.php');
}
/* Get user access tokens out of the session. */
$access_token = $_SESSION['access_token'];

/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,     $access_token['oauth_token'], $access_token['oauth_token_secret']);

/* If method is set change API call made. Test is called by default. */
$content = $connection->get('account/verify_credentials');

正如书中所说,从index.php开始,它的确会重定向到“ connect.php”页面,就好像我根本没有在KEY变量中放任何东西一样。

好了朋友们。 看起来好像不喜欢我为另一个脚本创建的“ twitter应用程序”(凭证)(该脚本有效)。 我只需要为本书的示例创建一个新的示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM