Задача:
Создать ленту на сайте, на которая бы обновлялась за счет Twitter'а, а именно - парсились бы новые сообщения с n-го количества акаунтов.
Хостинг виртуальный, и процессорной мощности не очень то и достаточно. Парсить 100 акаунтов при помощи simplexml_load_file или preg_match.
Есть ли какие то способы попроще?
Спасибо
Да и ошибки начали выскакивать.
Код:
Warning: simplexml_load_file(http://twitter.com/statuses/user_timeline/23931779.rss) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in test.php on line 9
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://twitter.com/statuses/user_timeline/23931779.rss"
Скорее всего лимит какой то на хосте стоит
В 9-й строке вот такое:
PHP код:
$rss = simplexml_load_file($r['link']);
Ссылка вроде как существует, и открыта для гостей
Вооще код моего скрипта вот такой:
PHP код:
<?php
include('config.php');
$sql = mysql_query("SELECT * FROM `de_twitter_users`");
$r = mysql_fetch_array($sql);
do {
echo $r['link'];
$rss = simplexml_load_file($r['link']);
foreach ($rss->channel->item as $item) {
$title = $item->title;
$description = $item->description;
$title = mb_convert_encoding($title, "windows-1251", "auto");
$description= mb_convert_encoding($description, "windows-1251", "auto");
$query_check = "SELECT `id` FROM `de_twitter` WHERE `cont` = '".addslashes($title)."'";
$sql_check = mysql_query($query_check);
$check = mysql_num_rows($sql_check);
if ($check == 0) {
$date = time();
$description = addslashes($description);
#$title = addslashes($title);
$sql = mysql_query("INSERT INTO `de_twitter`
(`cont`, `date`, `user` )
VALUES ('$description', '$date', '$r[id]');");
}
}
} while($r = mysql_fetch_array($sql));
?>