上传图片/照片/图片Facebook的(机器人) [英] Upload picture / photo/ image facebook (android)

查看:239
本文介绍了上传图片/照片/图片Facebook的(机器人)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的官方Facebook库,我完全发布的照片​​。
但是我有一个疑问。当您发布的第一次,图像将出现在墙壁上面的邮件中。但是,当你张贴第二次,它不会创建一个新的职位时,previous后期编辑,并说2加照片。

I'm using the official Facebook library and I publish photos perfectly. But I've a doubt. When you post for first time, the image appears in the message above the wall. But when you post for second time, it doesn't create a new post, the previous post is edited and says "2 pictures added".

如果帖子位于墙底部,并重新发布的照片​​中,我们将不会看到任何消息上方,将在内部邮件中公布。这将是为隐藏。
您可以创建一个新的岗位上一切我上传照片的时间?这怎么可能?

If the post is located at the bottom of the wall, and re-post a photo, we will not see any message at the top, will be released in the inner message. This will be as hidden. Can you create a new post every time I upload a photo? How is it possible?

我与你分享我的code工作也有人可以帮助。谢谢你。

I share with you my code works also anyone can help. Thank you.

mFacebook = new Facebook(APP_ID);
mFacebook.authorize(Principal.this, new String[]{ "user_photos,publish_checkins,publish_actions,publish_stream"},new DialogListener() {
@Override
public void onComplete(Bundle values) {
    postImageonWall();
     }
 @Override
 public void onFacebookError(FacebookError error) {
     }
 @Override
 public void onError(DialogError e) {
     }
 @Override
 public void onCancel() {
     }
  });

PostWall:

public void postImageonWall() {

        byte[] data = null;

          Bitmap bi = BitmapFactory.decodeFile(fotomontatgeInSD);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
          data = baos.toByteArray();


          Bundle params = new Bundle();
          params.putString(Facebook.TOKEN, mFacebook.getAccessToken());
          params.putString("method", "photos.upload");
          params.putByteArray("picture", data);

          AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(mFacebook);
          mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null);
 }


public class SampleUploadListener extends BaseRequestListener {

 public void onComplete(final String response, final Object state) {
     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());
     }
 }

 @Override
 public void onFacebookError(FacebookError e, Object state) {
     // TODO Auto-generated method stub

 }
}

我刚刚发现新的Facebook的设计解决了这个问题。

推荐答案

私人无效sharePhotoToFacebook(){
        位图图像= BitmapFactory.de codeResource(getResources(),R.drawable.f1);

private void sharePhotoToFacebook() { Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.f1);

    SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(image)
            .build();

    SharePhotoContent content = new SharePhotoContent.Builder()
            .addPhoto(photo)
            .build();

    ShareApi.share(content, null);

}

这篇关于上传图片/照片/图片Facebook的(机器人)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆