I've used GraphObject to share user story here is my object.
Bundle params = new Bundle();
params.putString("reward", permaLink);
params.putBoolean("fb:explicitly_shared", true);
GraphRequest request = new GraphRequest(
MainActivity.getInstance().mSimpleFacebook.getAccessToken(),
"me/rewardster:redeem",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse graphResponse) {
Log.i(TAG, graphResponse.toString());
}
}
);
request.executeAsync();
It works fine, is it possible for me to share it via ShareDialog, so user can add text to it or tag someone from friend list. etc?
If my current code is not good with share dialog please help me translating my graph object to some other model which is compatible with share dialog.
Its possible in IOS by the way.
There must be some way out of it in android as well.
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = #"rewardster:redeem";
[action setString:rewardObj.fbStoryLink forKey:#"reward"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = #"reward";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
NO, if you use share dialog you cant customize much[there is few flexibilty], hence to customize the post as a story and add custom fields and to modify the post we use graph stories check out the link https://developers.facebook.com/docs/sharing/opengraph. Both allows you to share but the post will look different.
to create a custom graph story refer this link
https://developers.facebook.com/docs/sharing/opengraph/custom
To achieve those custom things that you have asked you need to use graph-api only
Related
I want my app to post on Facebook and later query that same post, so that I can find the number of likes it received.
Is it possible? How do we do it?
Publishing API documentation from Facebook
The result is the post id, so just save this somewhere in the local storage with other post ids.
When you want to get the number of likes, use:
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{YOUR_POST_ID}/likes",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
You must set summary = true
This returns a summary element with a total_count field.
Documentation can be found here
I am trying to get friend list using me/frineds tag. There is no user of the app so far so i have added some frirneds as a tester of the app. But they are not showing in the response i am getting empty data list. Please guide me what i am doing wrong here. Here is the code
Bundle required = new Bundle();
required.putString("fields", "id, name, picture.type(square), gender, email");
//Request for friendlist from facebook
Request req = new Request(session, "me/friends", required, HttpMethod.GET,
new Callback() {
#Override
public void onCompleted(Response response)
{
is2=response.getGraphObject();
JSONObject json = is2.getInnerJSONObject();
readResponse(json);
String str = json.toString();
saveFileOnSD("data", str);
// generateNoteOnSD("frinedresponse", str);
Log.v(TAG, str);
}
});
Request.executeBatchAsync(req);
With v2.0, only users who are using the App too show up in the friend list. It is not enough to add someone as Tester in the App Settings, a user has to authorize your App.
See changelog for more information: https://developers.facebook.com/docs/apps/changelog
There is also "invitable_friends" and "taggable_friends", the first one is for game invitations only and the second one is for tagging only.
This has been previously asked, and the thread listed below has a ton of details. The only work around is if your app is a game. Here is the link to the other post: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app
I'm attempting to retrieve the total number of likes for a selected Facebook Page POST
According to this page:
How to get Likes Count when searching Facebook Graph API with search=xxx
I've tried to refer to the answers in that post and to build my code based on that.Here's the current code that I have based on it
private void totalLikes(String post_id){
Bundle bun = new Bundle();
bun.putString("summary","true");
new Request(Session.getActiveSession(), post_id+"/likes/",bun, HttpMethod.POST,
new Request.Callback() {
#Override
public void onCompleted(Response response) {
Toast.makeText(getBaseContext(),String.valueOf(response),Toast.LENGTH_SHORT).show();
}
}).executeAsync();
}
Unfortunately the response given is not what was expected,I was thinking that it could be due to my Bundle parameters.So I would like to know what are the actual bundle parameters I should be putting for the code?Thank you for the help :)!
In your Bundle string addition, try changing it to bun.putString("fields","likes.summary(true)"); and change the graph path to just the post_id. There should end up being a "summary" field in the response after that.
EDIT: Here's another method that might work better with permissions.
Graph path: post_id + "/likes"
with
bun.putString("include_summary", "true");
I tried messing around in the explorer and couldn't get it to work, but you might have better luck.
I have made a lot of combinations to get this working but I'm always getting an empty json, however in the Graph API Explorer it works very well, I'm using this statement to get the id of the albums from a X user:
SELECT aid from album WHERE owner = XXXXXXXXXX
it is returning (for example):
{
"data": [
{
"aid": "xxxxxxx_xxxx"
},
{
"aid": "xxxxxxxx_xxx"
}
]
}
in the drop down menu (where normally is Graph Api explorer selected) I have changed for my app, also I'm using the button "get access token" and selecting: "user_photos","friends_photos","user_friends" permissions,
but in my android app only I retrieve an empty json, (note: I have used another statement to recover user data (such as birthday) with this code, and works fine so code is correct, note2: I'm using the "user_photos","friends_photos","user_friends" permissions inside the app).
the code of the app (the fragment) is:
mynewbutton = (Button) view.findViewById(R.id.mynewbutton);
mynewbutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(final View v) {
String fqlQuery = "SELECT aid from album WHERE owner = XXXXXXXXX";
Bundle params = new Bundle();
params.putString("q", fqlQuery);
Session session = Session.getActiveSession();
// params.putString("access_token", session.getAccessToken());
Request request = new Request(session,
"/fql",
params,
HttpMethod.GET,
new Request.Callback(){
public void onCompleted(Response response) {
//Log.i(TAG, "Result: " + response.toString());
}
});
Request.executeBatchAsync(request);
}
});
Possible the reason is cuz I'm not getting the "valid access_token" inside the app.
So it came some questions in mind:
1.-How do I get the access_token?
2.-Do I need to use the method getAccessToken()?
3.-If so, How do I integrate in my code?
4.-Is it necessary to change something in the Graph Api Explorer in order to get working well in the app?
5.- Am I missing something (a step or a piece of code for example)?
6.-In general, How do I get the aid from album inside my app just like in the Graph Api Explorer? thanks.
I'm developing app which post images to facebook. That's working quite good. But my problem is that i can't find sample that would delete selected photo from facebook. I have allready made an function that gets the WallId and PhotoID from facebook.
My problem is that i can't get what should i put in facebook runner.request i know that i need to pass DELETE and PhotoId my function currently is
private void delete_fb(){
AsyncFacebookRunner fruner = new AsyncFacebookRunner(facebook);
Bundle params = new Bundle();
params.putString("fields", "id,name");
if(favi.get(indeks).fbid!=0 && WallId != 0){
fruner.request("me/"+WallId+"/"+favi.get(index).fbid,params ,"DELETE",new Del(),null);
}
}
So if you could explain me what to put in place of "me/"+WallId+"/"+favi.get(index).fbid in fruner.request() or give me some example code i would be very pleased.
Thank you.
try this
fruner.request(YourPostId, params ,"DELETE", new Del(), null);