Facebook Share - Missing Texts

Original problem

I did some more research, see the information at the bottom of the post. Thanks!

I have an Android app with the Facebook sharing option. I used part of the application mainly from the Fb tutorial. Deviation site, see: https://developers.facebook.com/docs/android/share

Here is the actual code:

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(); 

My problem is that the shared link does not contain all the texts that I entered in bundle . See Figure:

Facebook share

When I run the debugger and debug the application, all postParams work fine, and bundle have all the texts, but the share looks the same (and does not have all the texts).
bundle throws an unexpected ClassNotFoundExceptions , but I think this is a bug in the IDE, see this SO question .

Debugging in the IDE

Missing texts do not match all phones. On some phones, the picture is missis too, but I'm sure the URL is correct.

I know that this worked 2-3 weeks ago, and until today no one has touched this code.

Can you help me what causes the problem?
Thanks!

Edit

I tried Facebook Graph API Explorer to send the same request and I have the same result (missing texts, etc.).

Here's the request:

The same query from the Graph API Explorer

Is it possible that the Graph API is wrong / broken? Has this changed in the last few weeks? The status page says the API is healthy.

Edit # 2

Ok, so if I want to share any link, the thoose attributes apply. But if I want to share the link with Google Play, the attributes will stop working.

+6
source share
2 answers

This probably caused my problem: the Google Play Store defines oauth tags in the code, so FB parses these tags instead of my content.

The best solution I have found is to link to a blank site where I redirect my users using JavaScript.

+2
source

Use Facebook dialoug instead

 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
source

Source: https://habr.com/ru/post/977982/


All Articles