Re: need help with code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 21, 2009 at 10:42, Chris Westbrook <westbchris@xxxxxxxxx> wrote:
> 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?

    Probably, but we'll need the error message and the code on the
offending line.  My guess from what you've shown in the code below is
that line 13:

        $to = new TwitterOAuth($consumerKey, $consumerSecret);

    .... is telling you that it doesn't know TwitterOAuth().  And if
that's the case, are you sure that it's properly defined and being
included as appropriate from twitterlib.php?


> <?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";);
>
> }
>
>
> }
> ?>



-- 
</Daniel P. Brown>
daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux