【发布时间】:2018-04-07 00:59:51
【问题描述】:
我已经生成了密钥和秘密,现在我不知道如何使用密钥和秘密,以便将数据从服务器获取到我的 Android 应用程序中。谁能告诉它的正确程序?我如何创建签名、nonce 和其他需要验证的东西?
【问题讨论】:
我已经生成了密钥和秘密,现在我不知道如何使用密钥和秘密,以便将数据从服务器获取到我的 Android 应用程序中。谁能告诉它的正确程序?我如何创建签名、nonce 和其他需要验证的东西?
【问题讨论】:
使用 Volley 库是连接 API 的最简单方法。例如
RequestQueue queue = Volley.newRequestQueue(this);
String url = this.apiURl; //you could store it as config at raw
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// do nice things with your beautiful response
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Handle error if any
}
});
queue.add(jsonObjectRequest);
Woocommerce 发送 json 响应,因此请使用 JsonObjectRequest,因此您无需再次将 String 转换为 Json。
希望这会有所帮助!
【讨论】:
?consumer_key={}&consumer_secret={}