Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Pobieranie danych z API
NexON39
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 9.04.2021

Ostrzeżenie: (0%)
-----


Witam

Chciałbym pobrać dane z API: https://ucp.paradise-rpg.pl/api/group/637 i nie do końca wiem jak się za to zabrać aby wyświetlić te dane z tablicy. Napisałby ktoś taki skrypt który wyświetli te dane?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
ohm
post
Post #2





Grupa: Zarejestrowani
Postów: 623
Pomógł: 144
Dołączył: 22.12.2010

Ostrzeżenie: (0%)
-----


Po prostu sprawdzany jest user-agent i bez blokowane jest żądanie.

Ogólnie polecam użyć curla, ale z file_get_contents też działa (IMG:style_emoticons/default/smile.gif)

  1. $opts = [
  2. "http" => [
  3. "method" => "GET",
  4. "header" => "Accept-language: en\r\n" .
  5. "User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-1
  6. ]
  7. ];
  8.  
  9. $context = stream_context_create($opts);
  10. $res = file_get_contents($url, false, $context);
  11. $data = json_decode($res, true);
  12. print_r($data);


Ten post edytował ohm 12.04.2021, 10:10:22
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 17:10