tags:

views:

124

answers:

2

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>";

    }
}

}
+3  A: 
$xml = this->twitterCapture();  

should be

$xml = $this->twitterCapture();  
Mark Baker
thanks fro the tip... but it doesn't seem to solve the problem,I still get the same error
rabidmachine9
So which is line 29?
Mark Baker
Line 29 is: echo "<div class='curvebox'>".$xml->status[$i]->text."</div>";
rabidmachine9
A: 

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.

Joseph