Java 如何在Android应用程序中使用WooCommerce REST API?

Java 如何在Android应用程序中使用WooCommerce REST API?,java,php,android,Java,Php,Android,我已经生成了密钥和密码,现在我不知道如何使用密钥和密码,这样我就可以将服务器上的数据输入到我的Android应用程序中。有人能告诉警察这件事的正确程序吗?如何创建签名、nonce和其他无法验证的内容?使用Volley库是连接到API的最简单方法。比如说 RequestQueue queue = Volley.newRequestQueue(this); String url = this.apiURl; //you could store it as config at raw

我已经生成了密钥和密码,现在我不知道如何使用密钥和密码,这样我就可以将服务器上的数据输入到我的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);
RequestQueue queue=Volley.newRequestQueue(this);
字符串url=this.apiURl//您可以将其存储为原始配置
JsonObjectRequest JsonObjectRequest=新JsonObjectRequest
(Request.Method.GET,url,null,new Response.Listener()){
@凌驾
公共void onResponse(JSONObject响应){
//用你漂亮的反应做好事
},new Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
//处理错误(如果有)
}
});
add(jsonObjectRequest);
Woocommerce发送json响应,因此使用
JsonObjectRequest
,这样就不需要再次将字符串转换为json


希望这有帮助!

如何处理消费者密钥和消费者机密?如果您检查了woocommerce REST api文档,您可以将这些密钥作为查询参数显示,我可以为Auth放置密钥和机密吗?
?消费者密钥={}和消费者机密={}
Sir我知道如何处理http请求,我也尝试过。我尝试过将consumer_key和cosumer_secret作为参数发送……但我在这里遇到了一个错误{“code”:“woocommerce_rest_cannot_view”,“message”:“抱歉,您不能列出资源”,“data”:{“status”:401}