php代码可以与mamp一起使用,但不能在ubuntu服务器上使用

php代码可以与mamp一起使用,但不能在ubuntu服务器上使用,php,session,ubuntu,twitter,mamp,Php,Session,Ubuntu,Twitter,Mamp,我已经开始研究TwitterPHP库,但我无法让它在我的ubuntu服务器上运行,但在我的mac上,使用mamp它可以毫无问题地运行 这是在我的服务器上不起作用的代码,但是在mamp中。是的,我有编辑配置文件 <?php /* Start session and load library. */ session_start(); require_once('twitteroauth/twitteroauth.php'); require_once('config.php'); /* B

我已经开始研究TwitterPHP库,但我无法让它在我的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.';
}

确保你已经安装了curl-对于ubuntu,应该像
sudo-apt-get-install-curl一样简单

还可以在
ini\u集('display\u errors',1)上打开PHP错误;

错误报告(E|u ALL | E|u STRICT)如果您没有从错误消息中获得任何线索。

在脚本中打开错误报告:ini\u set('display\u errors',1);错误报告(E|u ALL | E|u STRICT);日志中的任何内容(/var/log/apache2/*如果未在其他地方配置)?您在本地和服务器上运行的PHP版本是什么?查看错误日志了吗/var/log/apache2/error.log(或者该目录可能包含每个virtualhost错误)。在服务器上,我使用版本5.3.2-1,在mamp版本5.2.11上,有一个错误,我认为是问题PHP致命错误:在第199行的/var/www/blomman/projects/test/ab/twitteroauth/twitteroauth.ph p中调用未定义的函数curl_init(),推荐人:xxx,但我有安装旋度吗?或者你需要安装其他东西吗?(apt get install curl)啊哈,php5 curl是个问题,这将是我的答案
<?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>