json - Google custom search api in android application -
I am trying to use Google Custom Search API for a school work and when I am trying to get results Get Jason's look, I've configured everything on the Google Developer Console and Google Custom Search Engine Control Panel, at least I think my code snippet here is and the error appearing in the logcat I appreciate a point in the right direction, I am doing something wrong. Please help! < Div class = "post-text" itemprop = "text"> I'm not sure whether this will help your situation, but I had a lot of trouble with my search string unless I do not know How to properly encode it I noticed that you are doing manual insertion of many codes (eg,% 20) and the methods of the object To work it might be more reliable. I'm not working in Java, but here's how I did it in C #. I encoded APIKey, CSKey and query separately and added all three to the base Google search string. Then I finally added "& alt = json". The string variable holds the returned string in 'Result'.
04-22 07: 26: 36.253: w / system. Er (4229): java Io.FileNotFoundException: https://www.googleapis.com/customsearch/v1?key%3DAIzaSyBgvvgYg3mYS66fMM9j0qpaG6wlvUc1KLk%26cx%3D008838294879486691568%3Axy_pvqrl6fa%26q%3Djava.pdf%26alt%3Djson%26start%3D0 04-22 07: 26: 36.289: W / System. Er (4229): at libcore.net.http.httpURLConnectionImpl.getInputStream (HttpURLConnectionImpl.java:186) 04-22 07: 26: 36.321: W / System. Er (4229): on libcore.net .http.httpsURLConnectionImpl.getInputStream (Http SURLConnectionImpl.javaailand71)
string myQuery = "action inspiration, Inc."; String end = string Format ("https://www.googleapis.com/customsearch/v1?key={0}&cx={1}&q={2}", HttpUtility.UrlEncode (APIKey), HttpUtility.UrlEncode (CXKey ), HttpUtility.UrlEncode (myQuery)); Last + = "& amp; alt = json"; WebRequest myRequest = WebRequest.Create (last); HttpWebResponse myResponse = (HttpWebResponse) myRequest.GetResponse (); Stream mystream = myResponse.GetResponseStream (); Streamminder Myrard = New Stream Reader (myResponse.GetResponsestream (), System.Text.Encoding.UTF8); String result = myReader.ReadToEnd ();
Comments
Post a Comment