2014-11-10 18 views
6

Vấn đề ban đầu

Tôi đã nghiên cứu thêm, xem thông tin ở cuối bài đăng. Cảm ơn!Facebook share - Thiếu văn bản

Tôi là một ứng dụng Android, với tùy chọn chia sẻ Facebook. Tôi đã làm phần chia sẻ của ứng dụng chủ yếu từ hướng dẫn về Fb. Dev. trang web, xem: https://developers.facebook.com/docs/android/share

Dưới đây là đoạn code thực tế:

Request.newMeRequest(session, new Request.GraphUserCallback() { 
    @Override 
    public void onCompleted(GraphUser user, Response response) { 
     Bundle postParams = new Bundle(); 
     String name = String.format(getResources().getString(R.string.shareFacebook_title), user.getName(), petName); 
     String caption = String.format(getResources().getString(R.string.shareFacebook_caption)); 
     String description = String.format(getResources().getString(R.string.shareFacebook_description), user.getName(), petName, shelterName); 
     postParams.putString("name", name); 
     postParams.putString("caption", caption); 
     postParams.putString("description", description); 
     postParams.putString("link", getResources().getString(R.string.shareFacebook_url)); 
     postParams.putString("picture", petPicUrl); 

     Request request = new Request(session, "me/feed", postParams, 
       HttpMethod.POST); 

     RequestAsyncTask task = new RequestAsyncTask(request); 
     task.execute(); 
    } 
}).executeAsync(); 

Vấn đề của tôi là, liên kết chia sẻ không có tất cả các văn bản, tôi đưa vào bundle. Xem pic:

Facebook share

Khi tôi chạy trình gỡ lỗi, và gỡ lỗi vào ứng dụng, tất cả các postParams chạy tốt, và Bundle có tất cả các văn bản, nhưng phần trông giống nhau (và không có tất cả các văn bản).
Bundle ném một số bất ngờ ClassNotFoundExceptions, nhưng tôi nghĩ rằng đó là lỗi trong IDE, hãy xem số SO question này.

Debugging in the IDE

Các văn bản còn thiếu không giống nhau trên tất cả điện thoại. Từ một số điện thoại, hình ảnh missis quá, nhưng tôi chắc chắn rằng URL là đúng.

Tôi biết, điều này đã hoạt động 2-3 tuần trước và không ai chạm vào mã này cho đến hôm nay.

Bạn có thể giúp tôi, điều gì gây ra sự cố không?
Cảm ơn!

Sửa

tôi đã cố gắng của Facebook Graph API Explorer, để gửi cùng một truy vấn, và tôi đã có kết quả tương tự (thiếu văn bản, vv).

Dưới đây là các truy vấn:

The same query from the Graph API Explorer

Có thể, rằng API Graph là sai/bị hỏng? Nó có thay đổi trong vài tuần qua không? Mã số status page cho biết rằng API có lợi cho sức khỏe.

Chỉnh sửa # 2

Ok, vì vậy nếu tôi muốn chia sẻ bất kỳ liên kết, thoose thuộc tính công trình. Nhưng nếu tôi muốn chia sẻ liên kết tới Google Play, các thuộc tính sẽ ngừng hoạt động.

Trả lời

2

lẽ đã gây ra vấn đề của tôi, rằng Google Play Store định nghĩa các thẻ oauth trong mã, vì vậy FB phân tích rằng các thẻ thay vì nội dung của tôi.

Giải pháp tốt nhất, tôi tìm thấy, là liên kết đến một trang web trống, nơi tôi chuyển hướng người dùng của mình bằng JavaScript.

0

Thay vì sử dụng này Facebook dialoug

private void publishFeedDialog() { 
    Bundle params = new Bundle(); 
    params.putString("name", "Facebook SDK for Android"); 
    params.putString("caption", "Build great social apps and get more installs."); 
    params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps."); 
    params.putString("link", "https://developers.facebook.com/android"); 
    params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png"); 

    WebDialog feedDialog = (
     new WebDialog.FeedDialogBuilder(getActivity(), 
      Session.getActiveSession(), 
      params)) 
     .setOnCompleteListener(new OnCompleteListener() { 

      @Override 
      public void onComplete(Bundle values, 
       FacebookException error) { 
       if (error == null) { 
        // When the story is posted, echo the success 
        // and the post Id. 
        final String postId = values.getString("post_id"); 
        if (postId != null) { 
         Toast.makeText(getActivity(), 
          "Posted story, id: "+postId, 
          Toast.LENGTH_SHORT).show(); 
        } else { 
         // User clicked the Cancel button 
         Toast.makeText(getActivity().getApplicationContext(), 
          "Publish cancelled", 
          Toast.LENGTH_SHORT).show(); 
        } 
       } else if (error instanceof FacebookOperationCanceledException) { 
        // User clicked the "x" button 
        Toast.makeText(getActivity().getApplicationContext(), 
         "Publish cancelled", 
         Toast.LENGTH_SHORT).show(); 
       } else { 
        // Generic, ex: network error 
        Toast.makeText(getActivity().getApplicationContext(), 
         "Error posting story", 
         Toast.LENGTH_SHORT).show(); 
       } 
      } 

     }) 
     .build(); 
    feedDialog.show(); 
} 
+0

Cảm ơn, nhưng tôi không muốn hiển thị bất kỳ hộp thoại nào, tôi muốn chia sẻ bài đăng mà không cần bất kỳ tương tác nào của người dùng. –

+0

oki sau đó bạn có thể sử dụng ý định shair – sukhbir

+0

sử dụng mã này ý định shair này sẽ làm việc với ứng dụng bản địa facebook – sukhbir

Các vấn đề liên quan