2013-07-12 26 views
9

Chúng ta có thể thay đổi hình ảnh của liên kết (nào được đăng tải bởi ứng dụng android) trên facebookChúng ta có thể thay đổi hình ảnh của liên kết (nào được đăng tải bởi ứng dụng android) trên facebook

Tôi đăng một số liên kết trên FaceBook qua của tôi ứng dụng, nhưng tôi muốn hình ảnh khác được hiển thị trên Facebook tường

mã của tôi đi như thế này

Intent shareCaptionIntent = new Intent(Intent.ACTION_SEND); 
shareCaptionIntent.setType("image/png"); 
shareCaptionIntent.putExtra(Intent.EXTRA_STREAM, "<URL>"); 
//set caption 
shareCaptionIntent.putExtra(Intent.EXTRA_TEXT, "example caption"); 
shareCaptionIntent.putExtra(Intent.EXTRA_SUBJECT, "example caption"); 
startActivity(Intent.createChooser(shareCaptionIntent,getString(R.string.share))); 

tôi có thể thấy chú thích và mô tả cũng có. Làm cách nào để thay đổi hình ảnh và hiển thị mô tả và chú thích, Vui lòng tìm hình ảnh đính kèm enter image description here

Trả lời

1

Không bạn có thể thay đổi liên kết của hình ảnh bạn đăng trên facebook. Facebook nó tự tạo ra liên kết này khi nó lưu trữ dữ liệu trong cơ sở dữ liệu đó.

4

Nếu bạn chỉ làm một phần, liên kết mà bạn đang chia sẻ được linted (phân tích) của Facebook và lấy các thẻ meta được xác định trên url đích mà bạn đang chia sẻ.

cụ thể cho câu hỏi của bạn:

<meta property="og:title" content="The Rock" /> 
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" /> 
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" /> 
<meta property="og:description" content="A great movie with Sean Connery and Nicolas Cage" /> 

Nếu bạn có quyền truy cập để thay đổi những thẻ meta, sau đó bạn có thể kiểm soát hình ảnh, tiêu đề và mô tả của bài đó sẽ được hiển thị trên Facebook.

Để tham khảo, hãy xem http://ogp.me/ cũng như sử dụng trình gỡ lỗi Facebook http://developers.facebook.com/tools/debug để lint (phân tích cú pháp) url mà bạn đang chia sẻ.

1
 **Using this code you can share any image from your drawable folder** 





    public void share() 
     { 
    Session.openActiveSession(this, true, new Session.StatusCallback() { 

      // callback when session changes state 
      @Override 
      public void call(final Session session, SessionState state, Exception exception) { 

      if (session.isOpened()) { 
       if(!session.getPermissions().contains("publish_actions")) 
         { 
        session.requestNewPublishPermissions(new Session.NewPermissionsRequest(Aboutcampaign.this, PERMISSIONS)); 
         } 
       else 
       { 
       final String message="YOUR STRING MESSAGE"; 
       // make request to the /me API 
       /* Request request = Request 
          .newStatusUpdateRequest(Session.getActiveSession(), message, new Request.Callback() { 
           @Override 
           public void onCompleted(Response response) { 
            showPublishResult(message, response.getGraphObject(), response.getError()); 
           } 
          }); 
        request.executeAsync();*/ 

       Bitmap image = BitmapFactory.decodeResource(Aboutcampaign.this.getResources(), R.drawable.product_btn); 
       // Bitmap BckGrnd = BitmapFactory.decodeFile(file); 
       Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), image, new Request.Callback() { 
        public void onCompleted(Response response) { 
         showPublishResult("Shared on Facebook", response.getGraphObject(), response.getError()); 

        } 
       }); 
       Bundle params = request.getParameters(); 
       // Add the parameters you want, the caption in this case 
       params.putString("name", message); 
       // Update the request parameters 
       request.setParameters(params); 

       // Execute the request 
       Request.executeBatchAsync(request); 
       // request.executeAsync(); 

       } 
      } 
      } 
     });