Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

[HTTP-Requests] cookies - SPTrans Olho Vivo

$
0
0

Hello

I'm building a visualization tool to get the immediate position of the buses available. There's this API that delivers these posions using a GET request. The return is a JSON.

I'm authenticating without problems, but when i request anything it blocks me any access. it's stinky documentation doesn't says that they need cookies to return the request.

The final product will be a mapped projection with this map, transported via syphon to another Resolume Arena. i need help in getting this cookie within this and processing it to get my requests.

import http.requests.*;

String baseURL="http://"+"api.olhovivo.sptrans.com.br/v0";
String token="2bc28344ead24b3b5fe273ec7389d2e4d14abd2bad45abe6d8d774026193f894";
String route="7272";

void setup() {
  size(1200, 1800);

  //API Olho Vivo
  authentication();
  getLinha(route);
}

void authentication() {
  String reqURL = "/Login/Autenticar?token=";
  PostRequest post = new PostRequest(baseURL+reqURL+token);
  post.send();
  println("Reponse Content: " + post.getContent());
  println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));
}

void getLinha(String busLIne) {
  String reqURL = "/Posicao?codigoLinha=";
  GetRequest get = new GetRequest(baseURL+reqURL+busLine);
  get.send();
  println("Reponse Content: " + get.getContent());
  println("Reponse Content-Length Header: " + get.getHeader("Content-Length"));
}

Responses:
Reponse Content: true
Reponse Content-Length Header: 4
May 15, 2017 12:05:34 AM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {}
Reponse Content: {"Message":"Authorization has been denied for this request."}
Reponse Content-Length Header: 61

API documentation: http://www.sptrans.com.br/desenvolvedores/APIOlhoVivo/Documentacao.aspx?1


Viewing all articles
Browse latest Browse all 2896

Trending Articles