0

Possible Duplicate:
Headers already sent by PHP

i don't know why if i call this file in standalone it works but if i call it inside my site it doesnt... but if i use the

echo "<br /><a href='".$url."'>Login with your Twitter account</a>" 

in place of

header("Location: ".$url."");

it works... i would like to automatize the process instead of asking everytime to connect with twitter.

the code:

<?php
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
switch ($connection->http_code) {
case 200:
$url = $connection->getAuthorizeURL($token);
//echo "<br /><a href='".$url."'>Login with your Twitter account</a>";
header("Location: ".$url."");
break;
default:
echo 'Could not connect to Twitter. Refresh the page or try again later.';
}
?>
Verv
  • 2,385
  • 2
  • 23
  • 37

1 Answers1

0

Make sure to remove any white spaces before the <?php opening tag.

Davide Gualano
  • 12,813
  • 9
  • 44
  • 65