Fórum Problemas com host estou aflito mesmo. #533558
05/10/2015
0
[img:descricao=imagem do Json retornado]http://arquivo.devmedia.com.br/forum/imagem/457038-20151005-022110.png[/img]
Quando busco com codigo java ele me retorna um html assim:
'
<html>
<body>
<script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("0a59286ff5362ff006f72140ec050474");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";location.href="http://joshua.byethost3.com/Church/congregacao.php?ckattempt=1";</script>
<noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
</body>
</html>
HTTP/1.1 400 Bad RequestServer: nginxDate: Sun, 04 Oct 2015 00:50:37 GMTContent-Type: text/htmlContent-Length: 166Connection: close
<html>
<head>
<title>400 Bad Request</title>
</head>
<body bgcolor="white">
<center>
<h1>400 Bad Request</h1>
</center>
<hr>
<center>nginx</center>
</body>
</html>
Lembrar que num antigo host funcionava normalmente...
Gabriel Manuel
Curtir tópico
+ 0Posts
05/10/2015
Joel Rodrigues
Como você está fazendo a requisição?
Gostei + 0
06/10/2015
Gabriel Manuel
Uso um codigo Java que vai e busca a informação na API vou anexar o codigo
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import org.json.*;
public class Dados_Congregacao {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
//hj
public List<Congregacao> Buscar_Igrejas_Proximas(String Email, String Cell) throws Exception {
List<Congregacao> lista = new ArrayList<>();
JsonObject user = new JsonObject();
// user.put("latitude", -19.49682827);
// user.put("longitude", 33.38936471);
Links congregacao_link = new Links();
URL myURL;
myURL = new URL(congregacao_link.getCongregacao());
HttpURLConnection myURLConnection = (HttpURLConnection) myURL.openConnection();
myURLConnection.setRequestMethod("POST");
myURLConnection.setDoOutput(true);
myURLConnection.setDoInput(true);
// System.out.println("GET <GETITEMS> dados : " + user.toString());
myURLConnection.connect();
OutputStream os = myURLConnection.getOutputStream();
DataOutputStream wr = new DataOutputStream(myURLConnection.getOutputStream());
String param = "Congregacao_coordenadas=" + URLEncoder.encode(user.toString(), "UTF-8");
wr.write(param.getBytes());
wr.flush();
wr.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
String inputLine, JSON_all = "";
while ((inputLine = reader.readLine()) != null) {
JSON_all = JSON_all + inputLine;
}//Toast.makeText(context,JSON_all,Toast.LENGTH_LONG).show();
System.out.println("RESPOSTA JSON" + JSON_all);
reader.close();
if (JSON_all.length() > 0) {
JsonParser parse = new JsonParser();
Object objecto = parse.parse(JSON_all);
JsonArray jsonArray = (JsonArray) objecto;
int contador = 0;
while (contador < jsonArray.size()) {
Congregacao congregacao = new Congregacao();
JsonObject jsonObject = (JsonObject) jsonArray.get(contador);
congregacao.setId(Integer.parseInt(jsonObject.get("id").toString()));
congregacao.setNome_congregacao(jsonObject.get("nome_congregacao").toString());
congregacao.setNome_lider(jsonObject.get("nome_lider").toString());
congregacao.setProvincia(jsonObject.get("provincia").toString());
congregacao.setDistrito(jsonObject.get("distrito").toString());
congregacao.setContacto(jsonObject.get("contacto").toString());
congregacao.setLatitude(jsonObject.get("latitude").toString());
congregacao.setLongitude(jsonObject.get("longitude").toString());
congregacao.setFoto(jsonObject.get("foto").toString());
congregacao.setDescricao(jsonObject.get("descricao").toString());
lista.add(congregacao);
contador++;
}
}
return lista;
}
}
Gostei + 0
06/10/2015
Joel Rodrigues
Gostei + 0
06/10/2015
Gabriel Manuel
Gostei + 0
06/10/2015
Joel Rodrigues
Gostei + 0
02/07/2020
Fabio Cunha.
Provavelmente você está usando um servidor gratuito, alguns servidores acrescentam código javascript para fazer uma verificação realizada por um bot.
No mcaso eu usava o infinityfree.com, agora passei a usar o 000webhost.com.
Ambos são gratuitos, no caso do 000webhost.com ele não faz essa conferência através de javascript, agora sem eu alterar nada no meu código, ele passou a funcionar corretamente.
Caso você troque para um provedor pago, provavelemente também não deve ter esse problema, mas sugiro que use o 000webhost.com e faça um teste pra ver se funciona.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)