0

I' making this class to catch twitter posts but I get the error :

Parse error: syntax error, unexpected T_STRING in /Applications/XAMPP/xamppfiles/htdocs/classTest/Twitter.php on line 29

I cant find what's wrong...any ideas?

class TwitterGrub{


function twitterCapture($user = 'myUsername',$password = 'myPass') {  


           $ch = curl_init("https://twitter.com/statuses/user_timeline.xml");  
           curl_setopt($ch, CURLOPT_HEADER, 1);  
           curl_setopt($ch,CURLOPT_TIMEOUT, 30);  
           curl_setopt($ch,CURLOPT_USERPWD,$user . ":" . $password);  
           curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
           curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);  
           curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);  
           $result=curl_exec ($ch);  
           $data = strstr($result, '<?');  

           $xml = new SimpleXMLElement($data);  

      return $xml;  

}  


function twitterDisplay($twitNum){
    $xml = this->twitterCapture(); 


    for($i= 0; $i<$twitNum; $i++){ 
    echo   "<div class='curvebox'>".$xml->status[$i]->text."</div>";

    }
}

}
5
  • Line 29 is: echo "<div class='curvebox'>".$xml->status[$i]->text."</div>"; Commented May 26, 2010 at 13:10
  • There is nothing wrong with your code. If I past your code to codepad.org (and fix this to $this) then it gets parsed without any error. Is it the correct file? Commented May 26, 2010 at 13:35
  • r u sure? I just did the same thing and I get an error on line 29... it is really strange... Commented May 26, 2010 at 13:53
  • here is the link: codepad.org/2yEKH4K4 Commented May 26, 2010 at 14:03
  • you didn't put the opening php tag on that codepad Commented Jun 21, 2013 at 6:03

2 Answers 2

4
$xml = this->twitterCapture();  

should be

$xml = $this->twitterCapture();  
Sign up to request clarification or add additional context in comments.

2 Comments

thanks fro the tip... but it doesn't seem to solve the problem, I still get the same error
Line 29 is: echo "<div class='curvebox'>".$xml->status[$i]->text."</div>";
0

The only reason I can find that you get the error you are getting is that you are not enclosing the code in php tags. Paste the following code into codepad, and you will get a different error (I have made no other changes to your code):

<?php
class TwitterGrub{


function twitterCapture($user = 'myUsername',$password = 'myPass') {  


           $ch = curl_init("https://twitter.com/statuses/user_timeline.xml");  
           curl_setopt($ch, CURLOPT_HEADER, 1);  
           curl_setopt($ch,CURLOPT_TIMEOUT, 30);  
           curl_setopt($ch,CURLOPT_USERPWD,$user . ":" . $password);  
           curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
           curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);  
           curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);  
           $result=curl_exec ($ch);  
           $data = strstr($result, '<?');  

           $xml = new SimpleXMLElement($data);  

      return $xml;  

}  


function twitterDisplay($twitNum){
    $xml = this->twitterCapture(); 


    for($i= 0; $i<$twitNum; $i++){ 
    //echo   "<div class='curvebox'>".$xml->status[$i]->text."</div>";

    }
}

}
?>

Then make the change from this

$xml = this->twitterCapture(); 

to

$xml = $this->twitterCapture();

and the errors will magically disappear.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.