PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : کار با api



mohsen_sh
January 31st, 2015, 18:57
بسم الله الرحمن الرحیم
سلام
من چند وقتیه ک سایت رو داخل این سایت : https://uptimerobot.com/ ست کردم! و حالا بعد از گذشت چند وقت آپتایم کاملا مشخص شده! و می خوام ک آپتایم رو به نمایش بزارم! (به صورت زنده)
خودشون نوشتن ک از طریق api ممکنه!
https://uptimerobot.com/api
می خواستم بدونم روش نوشتنش چ جوریه؟
حقیقتش اصلا با api کار نکردم!
ممنون می شم ک کمک کنید

us12
January 31st, 2015, 23:27
خودشون که کامل توضیح دادند !
اینم نمونه کدش :



<?php
/*Note: You'll need the ID of the monitor. For that, simply go to "http://api.uptimerobot.com/getMonitors?apiKey=yourApiKey" and get the ID of the monitor to be queried.*/
/*And, this code requires PHP 5+ or PHP 4 with SimpleXML enabled.*/

/*Variables - Start*/
$apiKey = "yourApiKey"; /*replace with your apiKey*/
$monitorID = 1111111; /*replace with your monitorID*/
$url = "http://api.uptimerobot.com/getMonitors?apiKey=" . $apiKey . "&monitors=" . $monitorID . "&format=xml";
/*Variables - End*/

/*Curl Request - Start*/
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$respon***ML = curl_exec($c);
curl_close($c);
/*Curl Request - End*/

/*XML Parsing - Start*/
$xml = simplexml_load_string($respon***ML);

foreach($xml->monitor as $monitor) {
echo $monitor['alltimeuptimeratio'];
}
/*XML Parsing - End*/
?>