need help with code
| From: | Chris Westbrook | Date: | Sat, 21 Mar 2009 14:42:31 +0000 |
| Subject: | need help with code | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-290494@lists.php.net to get a copy of this message | ||
I hate asking for help with simple code like this because I can usually figure it out, but I'm
stumped on this one. I'm getting a parser error on line 13, whether I comment out the
require_once line or not. Can you help?
<?php
require_once('twitterlib.php');
$consumerKey="yVVRd1QCJYBtT8tT7ocg";
$consumerSecret="DHzhJYOP2hBWfHpHawGxRQEFf98nF4TBTfabel2ukE";
$accessToken = $_COOKIE['accessToken'];
$reqToken = $_COOKIE['reqToken'];
if ($accessToken===NULL)
{
if ($reqToken === NULL)
{
//get a req token
$to = new TwitterOAuth($consumerKey, $consumerSecret);
$tok = $to->getRequestToken();
$reqToken = $tok['oauth_token'];
$reqTokenSecret = $tok['oauth_token_secret'];
$request_link = $to->getAuthorizeURL($toc);
$content = 'Click on the link to go to twitter to authorize your account.';
$content .= '<br /><a
href="'.$request_link.'">'.$request_link.'</a>';
setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/');
setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/');
?>
<html<head><title>authorize</title></head><body>
<?php echo $content;?>
</body></html>
<?php
}
else
{
/* If the access tokens are already set skip to the API call */
if ($_COOKIE['accessToken']===NULL)
{
/* Create TwitterOAuth object with app key/secret and token key/secret from default phase */
$to = new
TwitterOAuth($consumerKey,$consumerSecret,$_COOKIE['reqToken'],$_COOKIE['reqTokenSecret']);
/* Request access tokens from twitter */
$tok = $to->getAccessToken();
/* Save the access tokens. Normally these would be saved in a database for future use. */
setCookie('accessToken',tok['oauth_token'],time()*24*60*60*30,'/')
setCookie('accessTokenSecret',tok['oauth_token_secret'],time()*24*60*60*30,'/')
header("location http://www.chriswestbrook.com/twitter/twitter.php");
}
}
?>