I have a simple Google Places Query string from https://developers.google.com/places/web-service/search.
The following URL shows a search for restaurants near Sydney.
https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants+in+Sydney&key=YOUR_API_KEY
But then my retrofit2 & Okhttp3 encodes it like this below:
https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants%2Bin%2BSydney&key=YOUR_API_KEY
Replacing every occurrence of "+" with "%2B". And i wish to stop this.
How do I achieve this please?
Edit
I just finished reading the Github issue https://github.com/square/retrofit/issues/1407 , No answer found
does this work for you ?
Call<List<Articles>> getArticles((#QueryMap(encoded=true) Map<String, String> options);
encoded =true should tell retrofit that the paramter is already encoded.
Related
I want to get list of videos from daily motion, i have registered in daily motion. it's retrieved API key and secret key but i have no idea what is the next step, i want to show the list of videos and show the detail.
I have referred https://developer.dailymotion.com/api but i could not find any way how to integrate in my application.
Please guys help to solve this!!!
In case you want to get videos only (no channel or playlist) You can simply do:
https://api.dailymotion.com/videos?page=2
Response will be paginated so you need to add page numbers
https://api.dailymotion.com/videos?page=2
You can also get more >10 results
https://api.dailymotion.com/videos?limit=100
I would recommend you to make a GET request using https://github.com/amitshekhariitbhu/Fast-Android-Networking this library and sending the API key in your request header. This is one of the best networking libraries and very easy to implement. Use .addHeaders("token", "1234") to add API key in your request.
Set up Retrofit and Moshi/Gson (Best Guide: https://guides.codepath.com/android/Consuming-APIs-with-Retrofit) and then it would be just calling an endpoint.
#GET("https://api.dailymotion.com/channel/music/videos")
Call<List<Video>> getVideos();
or
#GET("https://api.dailymotion.com/user/{userId}")
Call<List<Video>> getVideos(#Path("userId") String userId);
And to use the Access Token:
#GET("https://api.dailymotion.com/videos?")
Call<List<Video>> getVideos(#Path("userId") String userId, #Query("sort") String sort);
I am trying to get google place details info like website,phone etc my code is work perfect but some time dose not display data but logcat to display response.
Use this url https://maps.googleapis.com/maps/api/place/detai/json?placeid="place id"&key="api key"
pls help me..
A Place Details request is an HTTP URL of the following form:
https://maps.googleapis.com/maps/api/place/details/output?parameters
where output may be either of the following values:
json (recommended) indicates output in JavaScript Object Notation (JSON)
xml indicates output as XML
Here is the Query URL :
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&key=YOUR_API_KEY
Currently when I call google rss/atom feed loader, I always get only 4 results in the response.
How can I get all the items in the response?
I need the results for my android app.
'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://www.digg.com/rss/index.xml'
I got the answer. I just need to add a "num" parameter to my query
https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://www.digg.com/rss/index.xml&num=30
The 'num' parameter does not work for 'find' method it only works for 'load' method. So I don't think there is any solution to this problem.
Use feed.setNumEntries(7); for retrieving more than 4 entries or number of items you want to retrieve.
var feed = new google.feeds.Feed("http://www.wsj.com/xml/rss/3_7085.xml");
feed.setNumEntries(7);
Read more: Google Feed API Developer's Guide
I am trying to send data using the following url but Its somehow being declared invalid query in Logcat
Base_URI/users/add.json?json={“email”: xxx#x.com, “password”: “xxxxxxxxx”, “first_name”: “Xyz”, “last_name”: “Xyz”}
I have asked this question before but found no solution so I am being more specific now.
The web services are made in cakephp as far as I know. Its not accepting url because of this part "json={}". Also the parameters are separated by ',' rather than '&'. In short, what encoding should I use to get json from it ?
I get this error in Logcat:
Illegal character in query at index 56
one more thing, No suggestions for third party library unless there is no solution in org.apache.http . By the way I tried Volley Library but had no success.
Finally after debugging and trying different solutions the whole day, I solved my own problem :)
I needed to encode the parameters part and not the whole URL like this:
String url = "Base_URI/users/add.json?json=";
url =url + URLEncoder.encode("{\"email\":\""+email+"\",\"password\":\""+password+"\"}", "UTF-8");
Thanks everyone for taking part in it !
Try this:
Base_URI/users/add.json?json={"email": "xxx#x.com", "password": "xxxxxxxxx","first_name": "Xyz", "last_name": "Xyz"}
All I want to do is to send a URL String into my RESTFUL web service with some kind of code like this
URL someURL= new URL("http://myWebService:port/service/"+CharSequence.getText());
Its all going well until I found error with space character in my URL. I found some solution about replacing the space character with %20 which is I already defined with something like this :
URL someURL= new URL("http://myWebService:port/service/"+CharSequence.getText().replace(" ", "%20"));
Everything, again, seems going well until i found that the replace(Char oldChara, Char newChara) function can only replace ONE space character, and not two.
For brief example when I send the CharSequence.getText() with values "We won" there will be no error, but when I change the values into "We won the battles" there will be an error issuing that there are some illegal character sent to my RESTFUL web service.
Any kind of answer will come up with my great thanks and big salute
~Regards~
Use replaceAll instead of replace.
Although, you should really be doing proper URL encoding. You can use URLEncoder.encode
for example.