내 사이트로드까지 약 45 초가 소요됩니다. 그것은 tumblr에서 일부 XML을 가져오고 있기 때문입니다. 그러나 이것이 내 서버의 잘못, tumblr의 잘못 또는 다른 요인인지는 알 수 없습니다. 이 스크립트를 5 초 만에 타임 아웃시키고 echo 'tumblr is down'할 수 있습니까? 거의 1 분 후에 그냥 시간 초과하는 대신에? 이 코드tumblr에서 가져 오기 위해 simplexml_load_file 사용 - 매번 시간 초과되었습니다.
Warning: simplexml_load_file(http://blog.yaytalent.com/api/read?type=post&start=1&num=2) [function.simplexml-load-file]: failed to open stream: Connection timed out in /nfs/c08/h02/mnt/122191/domains/yaytalent.com/html/index.php on line 86
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://blog.yaytalent.com/api/read?type=post&start=1&num=2" in /nfs/c08/h02/mnt/122191/domains/yaytalent.com/html/index.php on line 86
:
는이 오류를 받고 있어요
이 경우<?php
$request_url = "http://blog.yaytalent.com/api/read?type=post&start=1&num=2";
$xml = simplexml_load_file($request_url);
$title = $xml->posts->post->{'regular-title'};
$post = $xml->posts->post->{'regular-body'};
$link = $xml->posts->post['url'];
$small_post = substr($post,0,270);
echo "<h2><a target=frame2 href='".$link."'>$title</a></h2>";
echo "<p>$small_post... <a target=frame2 href='$link'>Read More</a></p>";
?>
당기는 문서의 빈도가 너무 많지 않은 경우 db 테이블에 저장하고 cron 또는 스케줄러로 자주 업데이트 할 수 있습니다 – Ibu
Ibu - 감사합니다. 프론트 엔드 기술을 갖춘 디자이너. 그런 식으로 쓰는 것이 내 머리 위에있다. – mike