android应用程序未在facebook上发布图像
嗨,我正在使用一个教程在facebook上发布图片,但它没有发布。请告诉我我做错了什么。我在手机上安装了facebook.apk。我已经完成了Facebook开发者Guide上描述的工作 这里是错误。。。。 这是另一节课android应用程序未在facebook上发布图像,android,facebook,sdk,photo,Android,Facebook,Sdk,Photo,嗨,我正在使用一个教程在facebook上发布图片,但它没有发布。请告诉我我做错了什么。我在手机上安装了facebook.apk。我已经完成了Facebook开发者Guide上描述的工作 这里是错误。。。。 这是另一节课 public class SampleUploadListener implements RequestListener { public void onComplete(String response, Object state) { // TODO Auto
public class SampleUploadListener implements RequestListener {
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
try {
// process the response here: (executed in background thread)
Log.d("Facebook-Example", "Response: " + response.toString());
JSONObject json = Util.parseJson(response);
final String src = json.getString("src");
// then post the processed result back to the UI thread
// if we do not do this, an runtime exception will be generated
// e.g. "CalledFromWrongThreadException: Only the original
// thread that created a view hierarchy can touch its views."
} catch (JSONException e) {
Log.w("Facebook-Example", "JSON Error in response");
} catch (FacebookError e) {
Log.w("Facebook-Example", "Facebook Error: " + e.getMessage());
}
}
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
public void onFileNotFoundException(FileNotFoundException e, Object state) {
// TODO Auto-generated method stub
}
public void onMalformedURLException(MalformedURLException e, Object state) {
// TODO Auto-generated method stub
}
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
}
您使用了错误的参数
检查像这样更改代码
Bundle params = new Bundle();
try {
Bitmap bMap = BitmapFactory.decodeFile(config.downloaded_image_path);
Log.i("Path",config.downloaded_image_path);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bMap.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm is the bitmap object
byte[] b = baos.toByteArray();
params.putByteArray("photo", b);
} catch (Exception e) {
e.printStackTrace();
}
params.putString("caption", config.facebook_comment);
Utility.mAsyncRunner.request("me/photos", params, "POST", new PhotoUploadListener(), null);
尝试将param的keyvalue更改为“photo”而不是“picture”,并且在请求方法中为GRaphApi提供null,这肯定是错误的 试试这个
这可能会对你有所帮助。好的,我成功登录,并发布了正确的回复
02-13 14:48:55.949: D/Facebook-Example(2814): Response: {"pid":"100002384000781_493454","aid":"100002384000781_53368","owner":100002384000781,"src":"http:\/\/photos-h.ak.fbcdn.net\/hphotos-ak-ash4\/400189_233648050057993_100002384000781_493454_803419378_s.jpg","src_big":"http:\/\/a8.sphotos.ak.fbcdn.net\/hphotos-ak-ash4\/400189_233648050057993_100002384000781_493454_803419378_n.jpg","src_small":"http:\/\/photos-h.ak.fbcdn.net\/hphotos-ak-ash4\/400189_233648050057993_100002384000781_493454_803419378_t.jpg","link":"http:\/\/www.facebook.com\/photo.php?fbid=233648050057993&set=a.233615786727886.53368.100002384000781&type=1","caption":"","created":1329124670,"object_id":233648050057993}
服务器的响应是什么?您不需要将
AccessToken
放在参数中。您好,您的意思是说这行,params.putString(Facebook.TOKEN,Facebook.getAccessToken());
02-13 14:48:55.949: D/Facebook-Example(2814): Response: {"pid":"100002384000781_493454","aid":"100002384000781_53368","owner":100002384000781,"src":"http:\/\/photos-h.ak.fbcdn.net\/hphotos-ak-ash4\/400189_233648050057993_100002384000781_493454_803419378_s.jpg","src_big":"http:\/\/a8.sphotos.ak.fbcdn.net\/hphotos-ak-ash4\/400189_233648050057993_100002384000781_493454_803419378_n.jpg","src_small":"http:\/\/photos-h.ak.fbcdn.net\/hphotos-ak-ash4\/400189_233648050057993_100002384000781_493454_803419378_t.jpg","link":"http:\/\/www.facebook.com\/photo.php?fbid=233648050057993&set=a.233615786727886.53368.100002384000781&type=1","caption":"","created":1329124670,"object_id":233648050057993}