Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Json
poczatkujaca12
post 22.12.2022, 12:44:04
Post #1





Grupa: Zarejestrowani
Postów: 107
Pomógł: 0
Dołączył: 24.06.2010
Skąd: Warszawa

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


Mam skrypt
  1. require_once 'HTTP/Request2.php';
  2. $request = new HTTP_Request2();
  3. $request->setUrl('https://linkDzialajacyWPostmanie');
  4. $request->setMethod(HTTP_Request2::METHOD_POST);
  5. $request->setConfig(array(
  6. 'follow_redirects' => TRUE
  7. ));
  8. $request->setHeader(array(
  9. 'Authorization' => 'Basic kluczPoprawny'
  10. ));
  11. $request->setBody('');
  12. try {
  13. $response = $request->send();
  14. if ($response->getStatus() == 200) {
  15. $json = $response->getBody();
  16. return $json;
  17. }
  18. else {
  19. return 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
  20. $response->getReasonPhrase();
  21. }
  22. }
  23. catch(HTTP_Request2_Exception $e) {
  24. return 'Error: ' . $e->getMessage();
  25. }

Ale dostaję:
Error: Request timed out due to default_socket_timeout php.ini setting

próbowałam dodać
  1. $request_stock->setConfig(array(
  2. 'follow_redirects' => TRUE,
  3. 'ssl_verify_peer' => FALSE,
  4. 'timeout' => 60
  5. ));

Ale bez efektów :/
Error: Request timed out after 60 second(s)
Go to the top of the page
+Quote Post

Posty w temacie
- poczatkujaca12   [PHP] Json   22.12.2022, 12:44:04
- - gino   Spróbuj uruchomić ten kod w sposób minimalistyczny...   22.12.2022, 14:00:14


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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 14:39