gpt4 book ai didi

java - 亚马逊休息电话通过安卓

转载 作者:太空狗 更新时间:2023-10-29 12:58:50 25 4
gpt4 key购买 nike

我想从 Android 执行对 Amazon API 的剩余调用。Amazon 要求所有 ws 调用都将使用 HMAC 签名(基于哈希的消息身份验证代码)进行身份验证。我缺少一个与 Apache Base64 对象类似的对象来签署我的请求。在 Android 中是否有一种简单的方法可以做到这一点,或者更好的是有一个用于亚马逊网络服务(产品广告 API)的 Android 客户端。

最佳答案

您应该能够在您的项目中只包含 Apache Base64 包。

看这个:http://www.delaytolerant.com/android-http-managing-base64-with-apache-commons-codec/

或者如果有任何基于 Java 的亚马逊客户端,您是否尝试过将这些 jar 包含在您的 Android 项目中?

显然上面的链接现在已经失效了。这是来自 Google's cache 的页面内容:

This post continues on programming HTTP within Android. In the following, I’ll show how to manage Base64 coded content in Android and how to render an image on WebView from a String that we encoded.

First, the tool to use is commons codec package from Apache. The documentation can be found here. The source is available here. You can just include the source of the package to your project, it is all Android compatible.

The commons codec package has also convenient method for Base64 decoding,

String imageString = "";
try {
FileInputStream fin = openFileInput("camera.jpg");
int jpeg_size = fin.available();
byte[] imagedata = new byte[jpeg_size];
fin.read(imagedata);
byte[] encodedData = Base64.encodeBase64(imagedata);
imageString = new String(encodedData);
final String mimetype = "text/html";
final String encoding = "UTF-8";
// replace below [ with html "<" and ] similarly ] with ">"
String html = "[html][body][center][img height=\"200\" width=\"200\"
src=\"data:image/jpeg;base64,"+imageString+"\"/][/center][/body][/html]";
mWebView.loadData(html, mimetype, encoding);
} catch (Exception e) {
e.printStackTrace();
}

There is also convenient Base64 decoding functionality in the package, which can be used for example, to decode Base64 encoded content in MIME messages, which were covered in previous post.

关于java - 亚马逊休息电话通过安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2200723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com