php code works with mamp but not on ubuntu server
Posted
by user355510
on Stack Overflow
See other posts from Stack Overflow
or by user355510
Published on 2010-06-01T14:24:08Z
Indexed on
2010/06/01
16:33 UTC
Read the original article
Hit count: 198
Hello,
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 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.';
}
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>
© Stack Overflow or respective owner