Reputation: 2436
I have been exploring the Facebook documentations but still yet to find on how to Check-in or share place. Most answers were already deprecated and I need to implement using the updated Facebook SDK. Did I miss something in the Documentations? Or do I have to use third party applications??? Besides the primary way of Sharing using the SDK, I also know how to use ACTION_SEND on sharing media content on facebook, is it possible to insert a place parameter there?
Upvotes: 0
Views: 467
Reputation: 572
The placeId needs to be requested using GraphRequest
which can be done using:
String facebookUrl = "https://www.facebook.com/mybusiness";
final String PAGE_ID_FROM_URL = facebookUrl.substring(facebookUrl.lastIndexOf("/") + 1, facebookUrl.length());//now PAGE_ID_FROM_URL = mybusiness
//request for page id
new GraphRequest(AccessToken.getCurrentAccessToken(), "/"+ PAGE_ID_FROM_URL , null, HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
JSONObject obj = response.getJSONObject();
if (obj.has("id")) {
try {
String pageID = obj.getString("id");
ShareDialog share = new ShareDialog(MyActivity.this);
ShareContent shareContent = new ShareLinkContent.Builder().setPlaceId(pageID).setPageId(pageID).build();
share.show(shareContent, ShareDialog.Mode.AUTOMATIC);
} catch (JSONException e) {
e.printStackTrace();
}
}
}).executeAsync();
Upvotes: 0
Reputation: 86
If you are using facebook share button it'll be like this
ShareContent sharecontent = new ShareLinkContent.Builder()
.setPlaceId("141887372509674")
.build();
btnfacebookshare.setShareContent(sharecontent);
Put a placeID on ShareContents
There are also ShareContent subclasses you may use with setPlaceId() like SharePhotoContent, ShareVideoContent, and ShareOpenGraphContent.
It is not clearly stated on the documentations (https://developers.facebook.com/docs/reference/android/current/class/ShareLinkContent/) but with experimentations I came up with it
Upvotes: 1