Get comment content - Facebook/Instagram Graph API - facebook-graph-api

Is it possible to get the parent comment (to whom I replied) using facebook graph api? For example:
user 1 - Hi,
//commented under user 1
user 2 - #xyz hello // I able to get the following comment using following endpoint
https://graph.facebook.com/17841405726653026
?fields=mentioned_comment.comment_id(17894227972186120)
how to get the user 1 comment? Sorry for such a bad explanation but I hope you got my point

Related

Display a variable in a Django form

I am trying to display a value from the database to a form. So if a user filled his email address, when he is connected he will see it in the email address form. I already did a post about this but I didn't get a lot of answer so I won't show my code this time but just ask you : Do you have an example of how to do it please ?
If someone need the answer to this question, check this post : How to display a variable in Django forms?
Now, stackoverflow bot think this should be a comment and not an answer so im just gonna paste some random code so he will leave me alone.
x = 1
if x == 1:
# indented four spaces
print("x is 1.")

how to get the page fan's comments from facebook api graph using koala gem

How to get the page fan's comments from facebook-api graph using koala gem
#user_graph = Koala::Facebook::API.new('XXXXXXXXXXXXX')
lists = #user_graph.get_object("#{pageid}/insights/page_storytellers")
but i want to get the all comments of the page fan's comments.
its giving null array results,
please anyone help me
Storytellers is a count of the unique people who created a story about your page post, it does not give you the full comment or info about the fan.
To get the comments on a page, you would have to first get a list of page posts, then query each post for comments.
You can get this info from any page, you do not need to have access to Insights.
For example:
page_info = #graph.get_object('nytimes')
pageid = page_info["id"]
fb_params = {
:fields => 'admin_creator,from,id,link,message,object_id,source,
status_type,story,story_tags,to,type,created_time,updated_time,
shares,likes.summary(true),comments.summary(true)',
:limit => 100,
:until => DateTime.now.at_end_of_day.to_i,
:since => DateTime.now.years_ago(5).to_i,
:metadata => 1
}
posts = #graph.get_connection(pageid, 'feed', fb_params)
If you include "comments.summary(true)" in the fields you request, you will get the first 25 comments on each post along with paging information (cursors, next and previous URLs).
Loop through each post and each post comment (and if you're up for it, comments on those comments), and you will have your result set.
If you prefer to skip writing the code, you could use Analytics Canvas to accomplish this task with a few clicks.
Full disclosure - I work with nModal on Analytics Canvas
You can do this with koala gem.
access_token = '#{access_token}'
#graph = Koala::Facebook::API.new(access_token)
page_name = '#{page_name}'
node_type = "posts"
# get posts with standard content
posts_standard = #graph.get_connections(page_name, node_type,limit: 5)
# get posts with replies
posts = #graph.get_connections(page_name, node_type, limit: 5,fields: "message,id,created_time,updated_time,likes.summary(true),shares,comments.fields(comments.fields(from,message),message,from),from")

How to get like count, comment count and share count for specific post in Spring-Social-Facebook

i'm using spring social facebook, but not able to get numbeer of like count, comments count and shares count for a specific post.
I have a post id and I'm using
fallowing code snippet
facebook.likeOperations().getLikes(MY_POST_ID);
facebook.commentOperations().getComment(MY_POST_ID);
I dint get any method to get share count
Using Spring Social Facebook
...
Facebook fb = new FacebookTemplate(fbToken, "your.fbapp.Namespace");
PagedList usersLikeThisPost = fb.likeOperations().getLikes(fbPostId);
Integer likes = usersLikeThisPost.size();
...
return likes;
Ref:
http://docs.spring.io/spring-social-facebook/docs/current/apidocs/
PagedList<Reference> getLikes(String objectId)
Retrieves a list of references to users who have liked the specified object. Limited to 25 references. Pass the PagingParameters returned from PagedList.getNextPage() into getLikes(String, PagingParameters) to get the next page.

Artist info missing from Facebook Graph API /music.listens endpoint

I'm playing around w/ the /me/music.listens endpoint of Graph API and I have it working just fine. Except I can't seem to figure out how to get actual artist info to come back. I see the song and even the album (though that seems a little inconsistent too). But never any artist info.
Check the developer explorer here: https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmusic.listens
No artist info. Is this just not returned? I can't see how to specify this in a fields param list. FB's documentation of the actions is spotty at best so I figured I'd try here.
Thanks!
I've figured out a work around. It doesn't look like Facebook actually returns artist info. So you have to use the Spotify Lookup Service (http://developer.spotify.com/technologies/web-api/lookup/).
To break it down a little further, you start by pulling the music.listens feed from FB and you'll get info that looks like:
(
[song] => Array
(
[id] => 381659191902248
[url] => http://open.spotify.com/track/**2Vv27Gc5k5GgGW9jgtj1CS**
[type] => music.song
[title] => Follow Through
)
)
From there, you need to grab the bolded track ID.
Lastly, fetch the song metadata with this call to Spotify: http://ws.spotify.com/lookup/1/.json?uri=spotify:track:2Vv27Gc5k5GgGW9jgtj1CS
You'll be returned the album name, artist info, etc.
If someone knows a better way, lemme know!
You can retrieve artists informations on graph API with the song id :
https://graph.facebook.com/song_id?fields=data{musician}
ex : https://graph.facebook.com/697975930266172?fields=data{musician}
Old question I know, but you can retrieve related information such as both the song title and artist title in the same request using Graph API's 'field expansion'.
For example - Last 10 songs
me?fields=music.listens.limit(10){data{song{title,id},musician{id,title}}}
To retrieve more information from either the song or musician entities just tweak the fields requested.
Note, this requires user_actions.music permission

Upload photo to an album AND to wall in facebook through php. So we get a big picture on wall

I manage to sent a photo from my server to a users album on facebook.
But this photo is not automaticly seen on his wall. And specifically it is not seen as a big photo, like how photos from albums are shown on a wall.
So I suppose I have to do a second request to tell facebook to put the photo on the wall.
I have these 2 requests:
$ret_obj = $facebook->api('/me/photos', 'POST',
array(
'source' => '#/var/www/cover/test.jpg',
'message' => $_POST['msg']
)
);
This returns for example:
[id] => 358313274248558 [post_id] => 100001736648729_358281023575116
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'message' => $_POST['msg'],
'object_attachment' => $ret_obj['id']
)
);
I have tried for the 'object_attachment' 358313274238558, 100001796648729_358281027575116 and 358281027575116. But facebook tells me that those are not correct.
So how on earth can we add a photo to a wall, which we just put in an album, and which we want to show in a large format (not as a little thumbnail).
If there is another way, without using albums, that is fine with me.
Please help. I know there have been a few questions already about photo uploads to facebook here on stackoverflow, I think I have read them all about 10 times already. It seems there is no answer yet. Somebody said we could post to /me/links but facebook doesn't seem to be able to handle links like http(s)://www.facebook.com/photo.php?fbid=358309510905631 anymore.
I have changed the ids in this post so they are not linked to actual stuff, they are here as examples.
Thanks
edit:
Ok, it seems a post of an image to an album is also a post of a big image to the wall IF the user allows the app to do public stuff. Because I was developing, I told the app to not do public stuff and only show stuff to me personally.
So there is no need to do 2 requests, just adding a photo to the album is enough to have it appear big on the users wall IF the user allows app activity to be public.
It is still somewhat confusing that a second request seems unable to also add the foto in a large size to the wall.