php code works with mamp but not on ubuntu server
I have start looking at a twitter php library http://github.com/abraham/twitteroauth, but i can't get it to work on my ubuntu server, but on my mac, with mamp it works without any problems.
This is the code that don't won't to work on my server, but in mamp. Yes i have edit config file
<?php
/* Start session and load library. */
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');
/* Build TwitterOAuth object with client creden开发者_如何学Ctials. */
$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.';
}
I have enable php session on my ubuntu server, because this code works
<?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>
Make sure you have curl installed - for ubuntu should be as easy as sudo apt-get install curl
Also turn your PHP errors on ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
if you're not getting any clues from error messages.
精彩评论