Re: [PHP] need help with code

2009-03-22 Thread VamVan
Code without proper indentation and is very hard to comprehend. You have
unnecessary spacing and line breaks that makes it difficult to debug.

I suggest you few things as a good practice:

1) Until you learn perfectly to code use some nice GUI editors that have
syntax highlighting (aptana, eclipse, zend etc).
2) Don't try to mix up markup (html) and api calls(PHP Code). Believe it
become a horrible mess to maintain after some point.

Anyways Here is your code with parse error removed:

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 .= ''.$request_link.'';
setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/');
setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/');

?>
authorize


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+3600,'/');

setCookie('accessTokenSecret',$tok['oauth_token_secret'],time()*24*60*60*30,'/');
  header("location http://www.chriswestbrook.com/twitter/twitter.php";);

}
  }
}
?>

Thanks,
V


Re: [PHP] need help with code

2009-03-21 Thread Virgilio Quilario
>> hi Chris,
>>
>> basing on the code you posted, you're missing the closing brace for
>> if ($accessToken===NULL)
>> {
>>
>> there should be 3 closing braces before the last ?>
>
>    That'll be the next error, but that error would print "unexpected
> $end on line xxx."

well, if you're getting the parse error without additional description
then it must be the php versions because the lib might be throwing
exceptions and you are running php4.

cheers,
Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques useful for
building and improving web sites.

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



Re: [PHP] need help with code

2009-03-21 Thread Daniel Brown
On Sat, Mar 21, 2009 at 10:54, Virgilio Quilario
 wrote:
>
> hi Chris,
>
> basing on the code you posted, you're missing the closing brace for
> if ($accessToken===NULL)
> {
>
> there should be 3 closing braces before the last ?>

That'll be the next error, but that error would print "unexpected
$end on line xxx."

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] need help with code

2009-03-21 Thread Virgilio Quilario
> 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?
>
>  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 .= ''.$request_link.'';
> setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/');
> setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/');
>
> ?>
> authorize
> 
> 
>  }
> 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";);
>
> }
>
>
> }
> ?>

hi Chris,

basing on the code you posted, you're missing the closing brace for
if ($accessToken===NULL)
{

there should be 3 closing braces before the last ?>

cheers,
Virgil
http://www.jampmark.com

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



Re: [PHP] need help with code

2009-03-21 Thread Daniel Brown
On Sat, Mar 21, 2009 at 10:42, Chris Westbrook  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?


>  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 .= ''.$request_link.'';
> setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/');
> setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/');
>
> ?>
> authorize
> 
> 
>  }
> 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.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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