Я использую HttpCilent 4.0.1 для загрузки изображения, но у меня есть HTTP 400 Error, сообщение об ошибке вроде этого, Plz мне кто-то помогает.Загрузка Facebook/SDK для передачи данных в формате multipart/form получена «Недопустимый токен доступа OAuth»
{ "Ошибка": { "Тип": "OAuthException", "сообщение": "Недопустимый маркер доступа OAuth "}}
Мой код ...
private void uploadPicture() throws ParseException, IOException {
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpPost httppost = new HttpPost("https://graph.facebook.com/me/photos");
File file = new File(sdpicturePath);
// DEBUG
Log.d("TSET", "FILE::" + file.exists()); // IT IS NOT NULL
Log.d("TEST", "AT:" + fbAccessToken); // I GOT SOME ACCESS TOKEN
MultipartEntity mpEntity = new MultipartEntity();
ContentBody cbFile = new FileBody(file, "image/png");
ContentBody cbMessage = new StringBody("TEST TSET");
ContentBody cbAccessToken = new StringBody(fbAccessToken);
mpEntity.addPart("access_token", cbAccessToken);
mpEntity.addPart("source", cbFile );
mpEntity.addPart("message", cbMessage );
httppost.setEntity(mpEntity);
// DEBUG
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
// DEBUG
System.out.println(response.getStatusLine());
if (resEntity != null) {
System.out.println(EntityUtils.toString(resEntity));
} // end if
if (resEntity != null) {
resEntity.consumeContent();
} // end if
httpclient.getConnectionManager().shutdown();
} // end of uploadPicture()
Спасибо за ваше сообщение ^^. – Joseph