Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Json
poczatkujaca12
post
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
 
Start new topic
Odpowiedzi (1 - 1)
gino
post
Post #2





Grupa: Zarejestrowani
Postów: 324
Pomógł: 52
Dołączył: 18.02.2008

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


Spróbuj uruchomić ten kod w sposób minimalistyczny, aby zobaczyć czy działa.
Co to jest? Gdzie to Cie odsyła?
Kod
$json = $response->getBody();
return $jason;
...
return 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .


Za manual PHP:
If called from the global scope, then execution of the current script file is ended...

Czy przypadkiem te returny nie zakańczają działanie skryptu?

Go to the top of the page
+Quote Post

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: 2.10.2025 - 21:19