Index: sandbox/webservice/restclient_new/css/styles.css =================================================================== --- sandbox/webservice/restclient_new/css/styles.css (revision 7808) +++ sandbox/webservice/restclient_new/css/styles.css (revision 7816) @@ -25,5 +25,5 @@ #content h3 { - font-size : 11; + font-size : 11pt; font-weight : bold; } @@ -45,7 +45,26 @@ } -#resources p +#exemplos_uso { - font-size : 12pt; + font-size : 11pt; + text-align: justify; +} +#exemplos_uso a +{ + color: red; + font-size: 12pt; + font-weight: bold; + text-decoration: none; +} + +#links_rel +{ + font-size : 11pt; + text-align: justify; +} + +#resources p +{ + font-size : 11pt; } Index: sandbox/webservice/restclient_new/index.html =================================================================== --- sandbox/webservice/restclient_new/index.html (revision 7808) +++ sandbox/webservice/restclient_new/index.html (revision 7816) @@ -124,5 +124,106 @@
+ Um exemplo de código de uma chamada AJAX, utilizando a Jquery. Este trecho de código abaixo representa + uma chamada para o Resource ExpressoVersion. +
+ ++ Este método retorna a versão do Expresso. Veja este exemplo funcionando em sua máquina baixando este projeto PROJETO.ZIP. +
+ ++
+ $.ajax( + { + type : "POST", + url : "client_rest.php", + data : + { + params : {}, + serverUrl : "http://expresso.pr.gov.br/api/rest/ExpressoVersion", + methodType : "POST" + }, + beforeSend: function() + { + // Coloque aqui seu código; + }, + success: function(response) + { + //Coloque aqui seu código; + }, + error: function(response) + { + //Coloque aqui seu código; + } + }; ++ + + +
+
+ <?php + + $serverUrl = $_REQUEST['serverUrl']; + $methodType = $_REQUEST['methodType']; + $params = $_REQUEST['params']; + $id = ( $_REQUEST['id'] ) ? $_REQUEST['id'] : time(); + + $data = "id=".$id."¶ms=" . stripslashes($params); + + function callJSONRPC($url, $data, $method) + { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + if($method == "POST"){ + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + } + + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded")); + + $result = curl_exec($ch); + $errorCode = curl_getinfo($ch,CURLINFO_HTTP_CODE); + $lastURL = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL); + + curl_close($ch); + + switch($errorCode) + { + case 200: + break; + + case 404: + $result = json_encode(array("error" => array("code" => 404, "message" => "RECURSO NAO ENCONTRADO => $lastURL"))); + break; + + case 500: + $result = json_encode(array("error" => array("code" => 500, "message" => "ERRO INTERNO. CONSULTE O LOG DO SERVIDOR"))); + break; + + default: + $result = json_encode(array("error" => array("code" => -1, "message" => "ERRO DESCONHECIDO. CONSULTE O LOG DO SERVIDOR"))); + break; + } + + return $result; + } + + $result = callJSONRPC($serverUrl, $data, $methodType); + + echo $result; + ?> + ++ +
Bibliotecas JavaScript Utilizadas
+ +Linguagem de programação Server Side
+Servidor WEB
+