ray Posted October 7, 2009 Report Share Posted October 7, 2009 man ir klase kurā ar load() tiek ielādēts *.xml fails no interneta lapas, bet ik pa brīdim šis fails nav pieejams (reizi pāris dienās uz īsu brīdi) un tad manā lapā rādās nesmuks error "...failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request...". Vai ir kāda iespēja, pirms tam pārbaudīt, vai šis fails man ielādēsies? Paldies! Quote Link to comment Share on other sites More sharing options...
briedis Posted October 7, 2009 Report Share Posted October 7, 2009 (edited) try - catch? Rekā es no twittera dabūju json datus, ik pa piecām minūtēm. Ja nav 5 min pagājušas, VAI serviss nav pieejams, tad ņemu lokālo failu. //Atjaunojam twittera JSON datus ik 5 minūtes function updateTwitter(){ $path = "myTwitterJson.json"; $url = "http://twitter.com/statuses/user_timeline/twitter_username.json?callback=twitterCallback2&count=6"; $stat = stat($path); $last_mod = (int)$stat[9]; //dabujam modificeto timestamp $delta_mins = time() - $last_mod; if($delta_mins > 300){ //defaultā 5 minūtes = 300 sekundes if($json_data = @file_get_contents($url)){ //Suppress warnings, ja neizdodas dabūt datus file_put_contents($path,$json_data); }else{ touch($path);//Pabakstam, lai nav jāmēģina atkal, ja neizdevās ielikt contentu } } } Edited October 7, 2009 by briedis Quote Link to comment Share on other sites More sharing options...
ray Posted October 7, 2009 Author Report Share Posted October 7, 2009 paldies, man tieši priekš twitter bija vajadzīgs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.