I'm trying to fetch YouTube Channel Videos and I'm getting an exception.
javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
Below is my Code.
strURL= https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=20
@Override
protected String doInBackground(Void... params) {
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(strURL);
// Response from the Http Request
HttpResponse response = httpClient.execute(httpPost);
StatusLine statusLine = response.getStatusLine();
// Check the Http Request for success.
if(statusLine.getStatusCode() == HttpStatus.SC_OK) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
response.getEntity().writeTo(byteArrayOutputStream);
content = byteArrayOutputStream.toString();
byteArrayOutputStream.close();
} else {
Log.w("HTTP1:", statusLine.getReasonPhrase());
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
Log.w("HTTP2:",e);
content = e.getMessage();
error = true;
} catch (IOException e) {
Log.w("HTTP3:", e);
content = e.getMessage();
error = true;
}
return content;
}