【发布时间】:2016-05-22 06:55:06
【问题描述】:
我有一个来自 aparat 站点的这个 api。我用这个方法搜索
http://www.aparat.com/etc/api/videoBySearch/text/[نوروز]
我应该用我的 editText 值填充最后一个参数。用于获取 json 。如果我发送english 字符串,它会起作用。但是如果我发送像 persian 这样的 unicode 字符串,它就无法工作,当我记录它时,它会说
java.lang.RuntimeException: Bad URL null
这是我的 JsonResponse 方法:
//this method call when search button pressed !
private void sendJsonRequest() {
String rawQuery = edtsearchQuery.getText().toString();
==> String first_url = "http://www.aparat.com/etc/api/videoBySearch/text/"+ rawQuery;
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, first_url, (String) null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
parseJsonResponse(response);
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("onErrorResponseSenJsReq" , error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(request);
}
【问题讨论】:
-
用什么语言开发的api?
-
我认为 php 。这个网站是公开的,我无法访问网站代码
-
要么按照@ρяσѕρєя-k 的建议进行编码。或者,您可以尝试以
POST发送而不是GET -
你看here了吗?