I'm currently researching facebook sdk.
I have googled around and just found some tutorial with like button for pages and haven't seen any tutorial for like button for posts.
So does facebook sdk 4.+ allow us to make an action like post?
If it does, can you guys show me some example please?
Thanks guys!
It's all written in the documentation:
Note: as of Nov 17, 2016 we changed the behavior of publishing likes and only support this action with Page Access Tokens.
https://developers.facebook.com/docs/graph-api/reference/v2.8/object/likes
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{object-id}/likes",
null,
HttpMethod.DELETE,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
Related
I am having an error in Android facebook app invite. Everything was working fine. I switched the account from Facebook and now I am getting this error.
if(AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(VPPreferences.getString(VPPreferencesKeys.INVITE_SCREEN_URL_FOR_FB, ""))
.setPreviewImageUrl(getString(R.string.invite_fbimage_url))
.build();
AppInviteDialog appInviteDialog = new AppInviteDialog(this);
sCallbackManager = CallbackManager.Factory.create();
appInviteDialog.registerCallback(sCallbackManager, new FacebookCallback<AppInviteDialog.Result>() {
#Override
public void onSuccess(AppInviteDialog.Result result) {
ToastNotificationUtil.showMessageToast(InviteSelectorScreen.this, getString(R.string.invite_succ));
}
#Override
public void onCancel() {
ToastNotificationUtil.showMessageToast(InviteSelectorScreen.this, "Invite canceled");
}
#Override
public void onError(FacebookException e) {
ToastNotificationUtil.showMessageToast(InviteSelectorScreen.this, "Invite failed ");
}
});
appInviteDialog.show(content);
}
Quoting from Facebook Developers there is a major change in their policy.
As of November 7, 2017, link customization is available however the
link must be owned by the posting page and a page access token is
required.
To verify ownership, check the
ownership_permissions{can_customize_link_posts} field on the URL node.
You must call this endpoint before posting new links.
Without this
step, custom link page posts will not work for un-scraped links. See
our Link Ownership Guide for more information.
For versions 2.10 and
lower, picture, name, thumbnail, and description are deprecated.
caption is deprecated for all versions.
Please go to the given link and change check the ownership_permissions{can_customize_link_posts} field on the URL node.
Hope this helps
I had the same issue Hamza, what I found is this:
As the latest release of Facebook SDK version 4.28.0 - November 7, 2017, App Invites is deprecated. https://developers.facebook.com/docs/app-invites/android/
With the release of the Facebook SDK version 4.28.0, App Invites is
deprecated. It will be supported until February 5, 2018.
I think the solution is to use another way to allow your users share your app with its friends like firebase dynamic links.
Hope it helps
I'm building an application to get the unread notification count for social medias (facebook, twitter)
Before api 2.4 what I'm suppose to do is to get permission from user to get their notification then do a
FBCount= new GraphRequest(AccessToken.getCurrentAccessToken(),
"/me/notifications?fields=unread",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}).executeAsync().toString();
But at api 2.4 it seems like it's impossible to get it anymore ?
Is there any possible way to the number of unread messages ?
No there is no way in v2.4. If you read the changelog https://developers.facebook.com/docs/apps/changelog you will see it was removed.
I have tried using the code below and if add old facebook sdk it workd fine but new sdk I get only the friend who is on app.How can I get the list of all friends in new sdk? .I really appreciate any help .Thanks in Advance.:
new Request(
MainActivity.facebook.getSession(),
"/me/friends",
null,
HttpMethod.GET,
new Request.Callback() {
#Override
public void onCompleted(Response response) {
/* handle the result */
Toast.makeText(activity, response.toString(), 5).show();
}
}
).executeAsync();
Short Answer: You CanĀ“t.
Since v2.0, you can only get the friends who authorized your App too, for privacy reasons. An App should not know about anyone who does not use the App.
If you want the names to tag them, there is taggable_friends. If you want to invite them, use invitable_friends. But check out the docs for their limitations.
I am trying to fetch friends' list in Facebook SDK 3.8 but it returning Empty User List.
I have also set the permissions of user_friends. Please see the following code.
<code>
LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList("user_friends"));
Request request = Request.newMyFriendsRequest(session, new Request.GraphUserListCallback() {
#Override
public void onCompleted(List<GraphUser> users, Response response) {
Log.i("activitytag", "UserListSize: " + users.size());
}
});
request.executeAsync();
</code>
I am getting the UserListSize to 0. What am I missing?
If you created your app after April 30, 2014, then you're using version 2.0 of the graph API, in which case the newMyFriendsRequest will only return friends who are also using your app. You should also update your SDK to the latest (3.14.1).
In facebook api v2.0 has no way to get all friends list.
but if you want to get all friend list ONLY IN GAME then you can call
Either
Invitable Friends List:
you may use the https://developers.facebook.com/docs/graph-api/reference/v2.0/user/invitable_friends API.
OR
Taggable Friends List:
the https://developers.facebook.com/docs/graph-api/reference/v2.0/user/taggable_friends
for more detail please read facebook change log:
Facebook Change log
I'm trying to discover if a user likes a specific facebook page by using Graph API inside an android application using the FB SDK v3.
The following call works and reports all of the likes of the user along with every other detail to do with each resulting item.
Request.executeGraphPathRequestAsync(session, "me/likes", new Request.Callback()
Since I'm not interested in any peripheral data, I just want to get the id back so I can lookup the page I'm interested in, but when I add the parameters as follows...
Request.executeGraphPathRequestAsync(session, "me/likes?fields=id", new Request.Callback()
... no object is returned from the call. If I post the same queries in the Graph API explorer they give back the expected results.
In addition to this question, is it at all possible to limit the result of the query to just the page ID to begin with, since I already know that piece of information? I have no use for the rest of the data being returned and would prefer not to chew up user bandwidth unnecessarily. I've searched high and low and it doesn't seem possible. Even the FQL explorer doesn't work when trying to limit by both user and page iD as the example suggests. I get an empty result set when adding 'AND page_id=xxx' to the query.
As far as i know, you cant run queries with field in 'executeGraphPathRequestAsync'.
instead use 'Request' and run in with 'RequestAsyncTask'.
Short example:
String grapPath = "me/home";
Bundle params = new Bundle();
params.putString("fields", "type,id,object_id,created_time,from,picture,likes");
params.putString("limit", "500");
Request request = new Request(session, grapPath, params, HttpMethod.GET, new Callback()
{
#Override
public void onCompleted(Response response)
{
if (response != null)
{
Log.d(TAG_NAME, "response: " + response.toString());
}
}
});
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
Hope i managed to help you :)
The Facebook SDK will add the "?access_token" to the end of the graph path string. So the graph command ends up looking like:
me/likes?fields=id?access_token
Break out the fields into a params Bundle.
Found this issue resolved in a Facebook bug post:
http://developers.facebook.com/bugs/314504765319932?browse=search_5116b87d245900257505334