【问题标题】:Pushbullet API via http in Android在 Android 中通过 http 的 Pushbullet API
【发布时间】:2015-04-09 20:52:38
【问题描述】:

如何在 Android 上通过 API-Key 接收 Pushbullet 备注/图像/个人资料详细信息?我的主要问题是在那一点上的 SSL 安全性。 (顺便说一句:我几乎是 Android 的初学者,只知道基础知识。)

身份验证如下所示:

https://apikey@api.pushbullet.com/v2/users/me

我正在通过

成功请求网页的内容(例如 wikipedia.org)
try {
    URL url = new URL("https://www.wikipedia.org");
    URLConnection urlConnection = url.openConnection();
    InputStream in = urlConnection.getInputStream();
    StringWriter writer = new StringWriter();
    IOUtils.copy(in, writer);
    theString = writer.toString();
    textView.setText(theString);
} catch (Exception e) {
    textView.setText("Error: "+e "String content: " +theString);
}

但是,例如,当我请求我的个人资料详细信息时,我总是会得到一个

javaio FileNotFoundException

【问题讨论】:

    标签: android api url https pushbullet


    【解决方案1】:

    如果您通过https://www.runscope.com 运行您的请求,您通常可以看到您的客户实际提出的请求是什么(他们有免费的试用计划)。

    如果我不得不猜测,我会说授权可能无法正常工作。您可以使用 curl 获取该页面吗?它应该类似于:

    curl -u <apikey>: https://api.pushbullet.com/v2/users/me
    

    假设可行,请尝试类似

    urlConnection.setRequestProperty("Authorization", "Bearer <apikey>");
    

    或者您在 HTTP 请求上设置标头。这比依赖https://password@domain url 更明确。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多