我已经开始查看一个twitter php库http://github.com/abraham/twitteroauth,但是我无法让它在我的ubuntu服务器上运行,但是在我的mac上,使用mamp它没有任何问题。
这是代码,不会在我的服务器上工作,但在mamp中。是的我有编辑配置文件
<?php
/* Start session and load library. */
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* Get temporary credentials. */
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
/* Save temporary credentials to session. */
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
/* If last connection failed don't display authorization link. */
switch ($connection->http_code) {
case 200:
/* Build authorize URL and redirect user to Twitter. */
$url = $connection->getAuthorizeURL($token);
header('Location: ' . $url);
break;
default:
/* Show notification if something went wrong. */
echo 'Could not connect to Twitter. Refresh the page or try again later.';
}
我在我的ubuntu服务器上启用了php会话,因为此代码可以正常工作
<?php
session_start();
$_SESSION["secretword"] = "hello there";
$secretword = $_SESSION["secretword"] ;
?>
<html>
<head>
<title>A PHP Session Example</title>
</head>
<body>
<?php echo $secretword; ?>
</body>
</html>
答案 0 :(得分:3)
确保已安装curl - 因为ubuntu应该像sudo apt-get install curl
一样简单
如果您没有从错误消息中获得任何线索,请在ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
上转换PHP错误。