I am developing an android app, and plan to make get requests to sites such as youtube and spotify. When I run this code through Eclipse, I get the response that I want. If I were to convert this code into an android app, will I still be able to generate the same results, or would I need the API's of youtube and spotify to do so?
This is the code I used to take a spotify song link and simply extract the song name from it. I do not want to use the Spotify API for such a basic function. If I were to put the code into an app, will I still be able to make the get request and get the information necessary?
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.*;
public class SpotAlgo {
String vidLink;
int linkLoc;
String testString = "<title>";
String result;
public String gettheResult(String v) throws Exception{
String sname = "";
vidLink = "https://open.spotify.com/track/6b8Be6ljOzmkOmFslEb23P";
URL obj = new URL(vidLink);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine = "";
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
result = response.toString();
linkLoc = result.indexOf(testString) + testString.length();
for (int i = linkLoc; i < result.indexOf("on Spotify"); i++) {
sname += result.charAt(i) + "";
}
return sname;
}
}