Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Zadanie 1</title>
- </head>
- <body>
- <?php
- $c = curl_init();
- curl_setopt($c, CURLOPT_URL, 'http://api.coderslab.pl/curl.php');
- curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30');
- $result = curl_exec($c);
- $httpCode = curl_getinfo($c, CURLINFO_HTTP_CODE);
- if ($httpCode == 404) {
- echo '404 - brak stronyu!';
- }
- if ($result) {
- /**
- * IP: adres_ip
- * SUMA: suma_pobranych_20_liczb
- * DEVICE: komputer/telefon
- */
- $resArr = explode('#', $result);
- echo 'IP: ' . $resArr[0] . '<br>';
- echo 'SUMA: ' . array_sum(explode(',', $resArr[1])) . '<br>';
- echo 'DEVICE: ' . $resArr[2] . '<br>';
- } else {
- echo 'Błąd: ' . curl_error($c);
- }
- curl_close($c);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment