Facebook Graph Api& Android - SSLPeerUnverifiedException:没有对等证书

时间:2015-04-04 13:03:02

标签: android json facebook facebook-graph-api

我想访问带有android的图形api URL。

public static String getResponseFromUrl(String url) {
        String xml = null;
        try {
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpGet httpPost = new HttpGet(url);
            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            xml = EntityUtils.toString(httpEntity);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return xml;
    }

我将此方法称为图表api url,例如

https://graph.facebook.com/v2.3/{ID}/feed?fields=message,object_id&filter=app_2305272732&access_token=token

我得到了

javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
04-04 15:54:59.077    1936-1991/com.fainosag.virginradiolebanon W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:146)
04-04 15:54:59.081    1936-1991/W/System.err﹕ at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
04-04 15:54:59.081    1936-1991/W/System.err﹕ at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388)
04-04 15:54:59.081    1936-1991/W/System.err﹕ at org.apache.http.impl.conn.DefaultClientConnectionOperator.updateSecureConnection(DefaultClientConnectionOperator.java:231)
04-04 15:54:59.089    1936-1991/  W/System.err﹕ at org.apache.http.impl.conn.AbstractPoolEntry.layerProtocol(AbstractPoolEntry.java:302)
04-04 15:54:59.089    1936-1991/ n W/System.err﹕ at org.apache.http.impl.conn.AbstractPooledConnAdapter.layerProtocol(AbstractPooledConnAdapter.java:146)
04-04 15:54:59.089    1936-1991/ W/System.err﹕ at org.apache.http.impl.client.DefaultRequestDirector.establishRoute(DefaultRequestDirector.java:654)
04-04 15:54:59.089    1936-1991/ W/System.err﹕ at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:370)
04-04 15:54:59.089    1936-1991/ W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
04-04 15:54:59.089    1936-1991/ W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
04-04 15:54:59.089    1936-1991/ W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
04-04 15:54:59.089    1936-1991/  W/System.err﹕ at com.fainosag.......http.HttpHelper.getResponseFromUrl(HttpHelper.java:30)

一切都在浏览器中运行。

0 个答案:

没有答案