]> _ Git - cubeextranet.git/commitdiff
fix #1952 @0.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 19 Feb 2018 09:46:54 +0000 (09:46 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 19 Feb 2018 09:46:54 +0000 (09:46 +0000)
inc/ws/Controlleur/class.ws.url.php

index 7e8ceb8f7f312379ee0107efddc9b7d65f37eef3..1795f26f7d4f0512888ec9ee808cab07b58d4158 100644 (file)
@@ -2100,37 +2100,42 @@ html{height:100%}' . "\n";
                return $res;
        }
 
-       public function orpiref($args) {
+       public static function orpiref($args) {
                $ref = $args[1];
 
+               try {
+                       $client = new Zend_Http_Client();
+                       $client->setAdapter('Zend_Http_Client_Adapter_Curl');
+                       $client->setEncType(Zend_Http_Client::ENC_FORMDATA);
+                       $client->setMethod(Zend_Http_Client::POST);
+                       $client->setParameterPost(array('reference' => $ref));
+                       $client->setUri('https://www.orpi.com/recherche/search_by_reference');
+                       $client->setHeaders(array('X-Requested-With' => 'XMLHttpRequest'));
+
+                       $response = $client->request();
+                       $json = $response->getBody();
+                       $res = 'https://www.orpi.com';
+                       echo $json;
+                       if ($json === false) {
+                               header('Location: ' . $res);
+                               exit;
+                       }
+                       $r = json_decode($json);
+                       if ($r === false) {
+                               header('Location: ' . $res);
+                               exit;
+                       }
 
-               $client = new Zend_Http_Client();
-               $client->setAdapter('Zend_Http_Client_Adapter_Curl');
-               $client->setEncType(Zend_Http_Client::ENC_FORMDATA);
-               $client->setMethod(Zend_Http_Client::POST);
-               $client->setParameterPost(array('reference' => $ref));
-               $client->setUri('https://www.orpi.com/recherche/search_by_reference');
-               $client->setHeaders(array('X-Requested-With' => 'XMLHttpRequest'));
-               $response = $client->request();
+                       if (isset($r->success) && $r->success && isset($r->location)) {
+                               header('Location: ' . $res . $r->location);
+                               exit;
+                       }
 
-               $json = $response->getBody();
-               $res = 'https://www.orpi.com';
-               if ($json === false) {
-                       header('Location: ' . $res);
-                       exit;
-               }
-               $r = json_decode($json);
-               if ($r === false) {
                        header('Location: ' . $res);
-                       exit;
+               } catch (Exception $e) {
+                       echo $e->getMessage();
                }
-
-               if (isset($r->success) && $r->success && isset($r->location)) {
-                       header('Location: ' . $res . $r->location);
-                       exit;
-               }
-
-               header('Location: ' . $res);
+               die('');
        }
 
 }