如何在Android中修改HTTP标头

时间:2017-01-08 19:39:53

标签: android api http-headers processing

我正在尝试制作足球数据API。我需要像这样修改我的http标头: 感谢您注册API身份验证令牌。请修改您的客户端以使用名为" X-Auth-Token"的HTTP标头。将下面的个人令牌作为价值。

您的API令牌:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

我尝试了2天但我无法正常工作。 (对不起,我是编程新手)。这是我的代码:

PImage button;

long Team; int shortName; int squadValue;

String url1 = "http://api.football-data.org/v1/teams/"; String
teamNumber = "66"; String url = url1 + teamNumber;

int refreshDelay = 5000; long lastTime;

void setup(){ background(#00DB17); size(1440, 2560); lastTime = 
millis()-refreshDelay;

fill(255); button = loadImage("voetbal.png"); imageMode(CENTER);
image(button,720,500);

fill(255); textSize(100); text("PRESS TO SEE TEAM", 300,350); }

void draw(){

if ((millis() - lastTime) > refreshDelay) { lastTime = millis();
if(mousePressed){
          if(mouseX>(500) && mouseX <(1040) && mouseY>(490) && mouseY<(790)){
            getInfo();
            fill(255);
            textSize(100);
            text("Team ID: "+teamNumber, 10, 1000);
            text("Team: "+Team, 10, 1300);
            text("Short Name: "+shortName, 10, 1600);
            text("Squad Market Value: "+squadValue, 10, 1900);
          }
    }    } }

void getInfo(){   try{
      JSONObject info = loadJSONObject(url); 
      Team = info.getLong("name"); 
      shortName = info.getInt("shortName"); 
      squadValue = info.getInt("squadMarketValue"); 

   } catch (Exception e) {
       println("rats...");
       } }

有人可以帮帮我吗?我如何在Android模式下执行此操作?

0 个答案:

没有答案