Krenuo sam da radim neku skriptu sa twitter api-jem, i desava mi se nesto cudno, naime:
Code:
$login = $user.':'.$pass;
$ch = curl_init();
$address = "http://api.twitter.com/1/friends/ids/".$user.".xml";
curl_setopt($ch, CURLOPT_URL, $address);
curl_setopt($ch, CURLOPT_USERPWD, $login);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$str = curl_exec($ch);
curl_close($ch);
preg_match_all('#<id>([^<]+)</id>#', $str, $matches); // Strip <id></id> tags from .xml
$i=0;
foreach($matches[0] as $k => $match) { // Count my followers
echo $i.': '.$matches[0][$i].'<br />';
$i++;
}
echo "<p>You have ".$i." followers!</p><br />"; // Show the amount of followers
$random_follower = $matches[0][rand(0,$i-1)]; // Pick a follower... any follower
echo '<p>Random Follower\'s ID: '.$random_follower.'</p><br />';
$ch = curl_init();
$tapi = 'http://api.twitter.com/1/friends/ids.xml?user_id='.$random_follower; //twitter api
curl_setopt($ch, CURLOPT_URL, $tapi);
curl_setopt($ch, CURLOPT_USERPWD, $login);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$str = curl_exec($ch);
curl_close($ch);
print_r($str);
$login = $user.':'.$pass;
$ch = curl_init();
$address = "http://api.twitter.com/1/friends/ids/".$user.".xml";
curl_setopt($ch, CURLOPT_URL, $address);
curl_setopt($ch, CURLOPT_USERPWD, $login);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$str = curl_exec($ch);
curl_close($ch);
preg_match_all('#<id>([^<]+)</id>#', $str, $matches); // Strip <id></id> tags from .xml
$i=0;
foreach($matches[0] as $k => $match) { // Count my followers
echo $i.': '.$matches[0][$i].'<br />';
$i++;
}
echo "<p>You have ".$i." followers!</p><br />"; // Show the amount of followers
$random_follower = $matches[0][rand(0,$i-1)]; // Pick a follower... any follower
echo '<p>Random Follower\'s ID: '.$random_follower.'</p><br />';
$ch = curl_init();
$tapi = 'http://api.twitter.com/1/friends/ids.xml?user_id='.$random_follower; //twitter api
curl_setopt($ch, CURLOPT_URL, $tapi);
curl_setopt($ch, CURLOPT_USERPWD, $login);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$str = curl_exec($ch);
curl_close($ch);
print_r($str);
rezultat daje tipa:
Code:
You have 50 followers!
Random Follower's ID: 12345678
/1/friends/ids.xml?user_id=<id>12345678</id> This method requires authentication.
You have 50 followers!
Random Follower's ID: 12345678
/1/friends/ids.xml?user_id=<id>12345678</id> This method requires authentication.
Ne mogu da 'provalim' zbog cega u echo izbacuje normalno, ali kada se prebacuje kroz variablu $tapi izbacuje klasican deo .xml-a
Mala pomoc? Neka glupost je u pitanju, koju ne vidim ..
<kow> "There are 10 types of people in the world... those who understand binary and
those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID
those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID