Changeset 7816 for sandbox/webservice
- Timestamp:
- 01/30/13 18:34:23 (12 years ago)
- Location:
- sandbox/webservice/restclient_new
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/webservice/restclient_new/css/styles.css
r7808 r7816 25 25 #content h3 26 26 { 27 font-size : 11 ;27 font-size : 11pt; 28 28 font-weight : bold; 29 29 } … … 45 45 } 46 46 47 # resources p47 #exemplos_uso 48 48 { 49 font-size : 12pt; 49 font-size : 11pt; 50 text-align: justify; 51 } 52 #exemplos_uso a 53 { 54 color: red; 55 font-size: 12pt; 56 font-weight: bold; 57 text-decoration: none; 58 } 59 60 #links_rel 61 { 62 font-size : 11pt; 63 text-align: justify; 64 } 65 66 #resources p 67 { 68 font-size : 11pt; 50 69 } 51 70 -
sandbox/webservice/restclient_new/index.html
r7808 r7816 124 124 <div id="exemplos_uso"> 125 125 126 <p></p> 126 <p> 127 Um exemplo de código de uma chamada AJAX, utilizando a Jquery. Este trecho de código abaixo representa 128 uma chamada para o Resource ExpressoVersion. 129 </p> 130 131 <p> 132 Este método retorna a versão do Expresso. Veja este exemplo funcionando em sua máquina baixando este projeto <a href="javascript:alert('Criar projeto')">PROJETO.ZIP</a>. 133 </p> 134 135 <p> 136 <h3>Enviando as informações com Javascript</h3> 137 138 <pre class='prettyprint'> 139 $.ajax( 140 { 141 type : "POST", 142 url : "client_rest.php", 143 data : 144 { 145 params : {}, 146 serverUrl : "http://expresso.pr.gov.br/api/rest/ExpressoVersion", 147 methodType : "POST" 148 }, 149 beforeSend: function() 150 { 151 // Coloque aqui seu código; 152 }, 153 success: function(response) 154 { 155 //Coloque aqui seu código; 156 }, 157 error: function(response) 158 { 159 //Coloque aqui seu código; 160 } 161 }; 162 </pre> 163 164 </p> 165 166 <p> 167 <h3>Recebendo as informações no PHP</h3> 168 169 <pre class='prettyprint'> 170 <?php 171 172 $serverUrl = $_REQUEST['serverUrl']; 173 $methodType = $_REQUEST['methodType']; 174 $params = $_REQUEST['params']; 175 $id = ( $_REQUEST['id'] ) ? $_REQUEST['id'] : time(); 176 177 $data = "id=".$id."&params=" . stripslashes($params); 178 179 function callJSONRPC($url, $data, $method) 180 { 181 $ch = curl_init(); 182 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 183 184 if($method == "POST"){ 185 curl_setopt($ch, CURLOPT_POST, 1); 186 curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 187 } 188 189 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 190 curl_setopt($ch, CURLOPT_URL, $url); 191 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded")); 192 193 $result = curl_exec($ch); 194 $errorCode = curl_getinfo($ch,CURLINFO_HTTP_CODE); 195 $lastURL = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL); 196 197 curl_close($ch); 198 199 switch($errorCode) 200 { 201 case 200: 202 break; 203 204 case 404: 205 $result = json_encode(array("error" => array("code" => 404, "message" => "RECURSO NAO ENCONTRADO => $lastURL"))); 206 break; 207 208 case 500: 209 $result = json_encode(array("error" => array("code" => 500, "message" => "ERRO INTERNO. CONSULTE O LOG DO SERVIDOR"))); 210 break; 211 212 default: 213 $result = json_encode(array("error" => array("code" => -1, "message" => "ERRO DESCONHECIDO. CONSULTE O LOG DO SERVIDOR"))); 214 break; 215 } 216 217 return $result; 218 } 219 220 $result = callJSONRPC($serverUrl, $data, $methodType); 221 222 echo $result; 223 ?> 224 225 </pre> 226 227 </p> 127 228 128 229 </div> … … 140 241 <li><a href='http://en.wikipedia.org/wiki/JSON-RPC#Implementations'>JSON-RPC Implementations</a></li> 141 242 </ul> 243 244 <p>Bibliotecas JavaScript Utilizadas</p> 245 246 <ul> 247 <li><a href='http://www.jquery.com'>JQuery-CORE</a></li> 248 <li><a href='http://www.jqueryui.com'>JQuery-UI</a></li> 249 <li><a href='http://http://embeddedjs.com'>EJS</a></li> 250 </ul> 251 252 <p>Linguagem de programação Server Side</p> 253 <ul> 254 <li><a href='http://www.php.net'>PHP</a></li> 255 </ul> 256 257 <p>Servidor WEB</p> 258 <ul> 259 <li><a href='http://www.apache.org'>Apache</a></li> 260 </ul> 261 142 262 </div> 143 263 -
sandbox/webservice/restclient_new/js/functions.js
r7808 r7816 15 15 $("#content_2").accordion( { collapsible: true } ); 16 16 17 prettyPrint(); 17 18 }) 18 19 }
Note: See TracChangeset
for help on using the changeset viewer.