I have come up to issues while I'm trying to write some classes, here is an example: I have this class called TwitterGrub and I cant call it like that:
$c = new TwitterGrub();
$c->twitterDisplay();
Burada sınıf kendisidir:
<?php
class TwitterGrub{
function twitterCapture($user = 'username',$password = 'pass') {
$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 = 2){
$xml = $this::twitterCapture();
for($i= 0; $i<$twitNum; $i++){
echo "<div class= 'curvebox'>".$xml->status[$i]->text."</div>";
}
}
}
?>
The problem is that everytime I want to change the username or password I have to jump back to class definition and that makes things not modular... and in many ways it feels wrong. So the question is what would be the proper way to chance my username and password through the objects interface and then call twitterDisplay() method with the new data?Hope that makes sense. Thanks in advance