Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1428 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  JSON of a bit...

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

JSON of a bit...

n°2473072
erwan83
Du Shift DEL tu te méfieras !
Posté le 22-06-2024 à 18:38:31  profilanswer
 

Bonjour. je lance un dernier appel ici car je pense être tombé sur un fichier JSON corrompu.
Voici le lien:
 
https://webminepool.com/api/PK_tdJJ [...] XnHP/users
 
La ligne s'affiche correctement quand on clique pour lire le JSON
Mais lorsque j'essaye de l'interprêter en PHP c'est la zone total.
 
Alors si un user balèze pouvait m'aider.
 
j'essaye :

Code :
  1. $json_data = json_decode($json,true);
  2. var_dump($json_data); //=> NULL => ???
  3. extract($json_data, EXTR_PREFIX_SAME, "wddx" );
  4. extract($hashes, EXTR_PREFIX_SAME, "wddx" );


Résultat: NULL

Code :
  1. $cu = curl_init($fiche);
  2. curl_setopt($cu, CURLOPT_HTTPHEADER, ['content-type' => 'application/json', 'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36']);
  3. curl_setopt($cu, CURLOPT_RETURNTRANSFER,true);
  4. $json = curl_exec($cu);


Résultat: mouline et plante...
 
Donc si jamais un fort en extraction JSON peut m'aider....
 
M E R C I

mood
Publicité
Posté le 22-06-2024 à 18:38:31  profilanswer
 

n°2473085
SICKofitAL​L
misanthrope
Posté le 22-06-2024 à 22:51:03  profilanswer
 

Salut
 
ca fonctionne chez moi.
 

Code :
  1. array(2) { ["success"]=> bool(true) ["users"]=> ..."erwanconan83@hotmail.com" ["hashes"]=> int(19692868) ["referral"]=> NULL ["updated_at"]=> string(19) "2024-06-22 18:52:04" } } }


 
Tu peux regarder quelle erreur est remontée :
https://www.php.net/manual/en/funct [...] -error.php
 
Pour info, mon PiHole a bloqué initialement cette url, il est donc possible selon ta config que ton curl ne chope rien en fait.
 

Code :
  1. $url = "https://webminepool.com/api/PK_tdJJk9qpJ22KnoZgHXnHP/users";
  2. $cu = curl_init ($url);
  3. curl_setopt ($cu, CURLOPT_RETURNTRANSFER, true);
  4. $jsonStr = curl_exec ($cu);
  5. curl_close ($cu);
  6. $data = json_decode ($jsonStr, true);
  7. var_dump ($data);


Message édité par SICKofitALL le 22-06-2024 à 22:53:17

---------------
We deserve everything that's coming...
n°2473087
erwan83
Du Shift DEL tu te méfieras !
Posté le 22-06-2024 à 23:43:05  profilanswer
 

Merci à to je vais tester


---------------
http://www.ypikay.com
n°2473088
erwan83
Du Shift DEL tu te méfieras !
Posté le 22-06-2024 à 23:52:32  profilanswer
 

Toujours en erreur on dirait qu'il cherche mais ne trouve pas
Voici le code
 

Code :
  1. $url = "https://webminepool.com/api/PK_tdJJk9qpJ22KnoZgHXnHP/users";
  2. $cu = curl_init ($url);
  3. curl_setopt ($cu, CURLOPT_RETURNTRANSFER, true);
  4. $json = curl_exec ($cu); // IL PLANTE SUR CETTE LIGNE
  5. curl_close ($cu);
  6. // $data = json_decode ($json, true);
  7. // var_dump ($data);
  8. foreach ($json as $string)
  9. {
  10.     echo 'Decoding: ' . $string;
  11.     json_decode($string);
  12.     switch (json_last_error()) {
  13.         case JSON_ERROR_NONE:
  14.             echo ' - No errors';
  15.         break;
  16.         case JSON_ERROR_DEPTH:
  17.             echo ' - Maximum stack depth exceeded';
  18.         break;
  19.         case JSON_ERROR_STATE_MISMATCH:
  20.             echo ' - Underflow or the modes mismatch';
  21.         break;
  22.         case JSON_ERROR_CTRL_CHAR:
  23.             echo ' - Unexpected control character found';
  24.         break;
  25.         case JSON_ERROR_SYNTAX:
  26.             echo ' - Syntax error, malformed JSON';
  27.         break;
  28.         case JSON_ERROR_UTF8:
  29.             echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
  30.         break;
  31.         default:
  32.             echo ' - Unknown error';
  33.         break;
  34.     }
  35.     echo PHP_EOL;
  36. }


Message édité par erwan83 le 22-06-2024 à 23:55:46
n°2473089
SICKofitAL​L
misanthrope
Posté le 22-06-2024 à 23:59:49  profilanswer
 

essaye avec curl_error, tu auras ptetre plus de détails :
https://www.php.net/manual/fr/function.curl-error.php
 

Code :
  1. curl_exec ($cu);
  2. if (curl_errno ($cu))
  3. {
  4.     die (curl_error ($cu));
  5. }
  6. curl_close ($cu);


---------------
We deserve everything that's coming...
n°2473090
erwan83
Du Shift DEL tu te méfieras !
Posté le 23-06-2024 à 00:02:57  profilanswer
 

Fichtre quel bordel, pour un code qui fonctionnait super avant.
Merci je teste


---------------
http://www.ypikay.com
n°2473091
erwan83
Du Shift DEL tu te méfieras !
Posté le 23-06-2024 à 00:15:17  profilanswer
 

Ca ne marche pas, vu qu'il tourne en rond juste avant la vérif.
J'ai mis un or die("erreur" ) apres curl_exec mais toujours rien
le var_dump me renvoie NULL au bout de xxx secondes


---------------
http://www.ypikay.com
n°2473092
erwan83
Du Shift DEL tu te méfieras !
Posté le 23-06-2024 à 00:19:06  profilanswer
 

Failed to connect to webminepool.com port 443: Connection timed out


---------------
http://www.ypikay.com
n°2473093
SICKofitAL​L
misanthrope
Posté le 23-06-2024 à 00:22:52  profilanswer
 

Comme dit plus haut, mon piHole (antipub+antinuisible) râle sur cette url, et d'ailleurs uBlock aussi !
 
Il est possible que ca soit bloqué chez toi par qqch sur ton réseau.
 
https://i.imgur.com/h0sKLoE.png


---------------
We deserve everything that's coming...
n°2473094
erwan83
Du Shift DEL tu te méfieras !
Posté le 23-06-2024 à 00:38:17  profilanswer
 

Ahhhh
Dans ce cas je suis un peu dans la m...
Je vais continuer de creuser
Merci !


---------------
http://www.ypikay.com

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  JSON of a bit...

 

Sujets relatifs
conversion fichier pdf en jsonScript CSV en JSON
Conversion csv vers jsonconversion requête sql XML -> JSON
[Java] Deserialization JSON et typageExcel - intégration de données JSON via requête sur site WEB
[MySQL] Extraction de champs Json[MySQL] Champs Json, ordre non gardé
[JAVASCRIPT] JSON.parse()Fichier JSON to string
Plus de sujets relatifs à : JSON of a bit...


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR