Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Wyciąganie danych JSON przez PHP
xaitras
post
Post #1





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 27.06.2017

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


Witam wszystkich forumowiczów

Borykam się z problemem od dłuższego czasu. Może ktoś pomoże..

Do tej pory wykombinowałem takie coś:

  1.  
  2. $params = array (
  3.  
  4. 'token' => 'xxx-xxx-xxxx-xxxx',
  5. 'method' => 'getOrders',
  6. 'parameters' => '{ "status_id": 36310}'
  7.  
  8. );
  9.  
  10. $query = http_build_query ($params);
  11.  
  12. $contextData = array (
  13. 'method' => 'POST',
  14. 'header' => "Connection: close\r\n" .
  15. "Content-Length: ".strlen($query)."\r\n",
  16. 'content'=> $query );
  17.  
  18.  
  19. $context = stream_context_create (array ( 'http' => $contextData ));
  20.  
  21. $result = file_get_contents ('https://api.baselinker.com/connector.php', false, $context);
  22.  
  23.  
  24. $dane = json_decode($result);
  25.  
  26. $w = var_dump($dane);
  27.  
  28. echo $w;
  29.  


Próbuję wyciągnąć wszystkie numery zamówień z danego statusu ( api baselinker )
Problem w tym, że nie wiem jak wyciągnąć tylko numery.. (IMG:style_emoticons/default/facepalmxd.gif) (IMG:style_emoticons/default/sad.gif)
Wyświetla mi wszystkie dane zamówienia.



Pozdrawiam i czekam na pomoc (IMG:style_emoticons/default/sciana.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
xaitras
post
Post #2





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 27.06.2017

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



Dzięki za podpowiedź..
Poćwiczę temat i odezwę się jeszcze.

To co mi wypluwa :

  1. Notice: file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded in C:\WebServ\httpd\test.php on line 25
  2. object(stdClass)#1 (2) { ["status"]=> string(7) "SUCCESS" ["orders"]=> array(18) { [0]=> object(stdClass)#2 (47) { ["order_id"]=> int(17314526) ["external_order_id"]=> string(9) "724800438" ["order_source"]=> string(7) "allegro" ["order_source_id"]=> string(4) "6136" ["order_source_info"]=> string(1) "-" ["order_status_id"]=> int(36310) ["confirmed"]=> bool(true) ["date_confirmed"]=> string(10) "1498243222" ["date_add"]=> int(1498242770) ["user_login"]=> string(10) "glizda2008" ["phone"]=> string(9) "338647108" ["email"]=> string(14) "Roza15@onet.eu" ["user_comments"]=> string(0) "" ["admin_comments"]=> string(0) "" ["currency"]=> string(3) "PLN" ["payment_method"]=> string(4) "PayU" ["payment_method_cod"]=> string(1) "0" ["payment_done"]=> int(0) ["delivery_method"]=> string(16) "Pocztex Kurier48" ["delivery_price"]=> int(13) ["delivery_package_module"]=> string(0) "" ["delivery_package_nr"]=> string(0) ""


itd..

Niestety

array_column nie zadziałało bo nie jest obsługiwane przez tą wersję PHP
próbowałem też z array_search, compact i nie wiem co robię źle..

Mógłbyś podać jakiś przykład, jak wyciągnąć chociaż jedną wartość np. numer pod "order_id" ?

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: 14.10.2025 - 16:16