0

I am creating a web application that displays a list of images taken from Flickr and I would like a user to login through Facebook and allow them to comment on those images. I was able to get the login/authentication working but I am now having trouble to enable a user to add a comment (as oppose to a Facebook 'post') on a Flickr image and have this activity show up on the user's Facebook profile/feed (i.e "John Smith commented on a link").

Here is what I have so far:

var fbCommentApi = '/me/myappname_ns:comment?access_token=' + fbUserToken + '&method=post' + '&picture=[WEBSITE_URL]' + selectedItemId;
FB.api(
    fbCommentApi,
    'post',
    { message: txtObj.value },
    function (response) {
        if (!response || response.error) {
            alert("Sorry, there was a problem. Please try again later. [API]");
        }
        else {
            alert("Thank you. Your comment will appear shortly");
            hideCommentBox(txtObj);
        }
    }
);

The above code doesn't create a comment but instead it creates a post on the user's timeline with the URL attached. So when I try to retrieve comments for the WEBSITE_URL item through Facebook Graph...

'https://graph.facebook.com/comments/?id=[WEBSITE_URL]' + itemID

...I end up with empty data being returned.

I have an Action Type called 'Comment' in my Facebook app and that's the action I am using when trying to add the comment.

Thanks in advance and I look forward to your answers.

UPDATE 1: It seems now that if I use Facebook Graph this way.. graph.facebook.com/me/appname_ns:discuss?access_token=[TOKEN]&website=[URL]&met‌​hod=post ..it would just add an entry to the user's Activity box in their timeline, I didn't even pass a comment or message parameter to the URL as a query string parameter. That could be part of the problem.

UPDATE 2: According to another StackOverflow question, there seems to be no way to get a view of all actions done by all users, it has to be done per user (an API call per user). Therefore another way of handling this particular issue is to save the comments (or whatever action performed) to our own database.

Community
  • 1
  • 1
ahmed.eltawil
  • 561
  • 4
  • 16

1 Answers1

0

Well, an Open Graph action is not a comment, even if you name it comment

If you want a real Facebook comment, then either get a reference to an object that actually can be commented upon; or substitute comment with post/link post.

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • The **Comment** action was selected from the dropdown list that shows up when you create a new open graph action. So I thought it does what it says it does, _commenting_. I still want the users to just add a comment to the picture object and not just post it on their wall. – ahmed.eltawil Jun 14 '12 at 12:58
  • I don’t have _Comment_ show up in that dialog, only the build-in types. – CBroe Jun 14 '12 at 13:28
  • Hmmm...I guess it shows up in my list because it's already created. I am going to create another action again and tweak it's properties and try it out. – ahmed.eltawil Jun 14 '12 at 14:33
  • OK, there is progress. I created a new action called it **Discuss** and with it's tweaked properties it was able to add an entry to the user's timeline activity as _John Smith discussed [item-title] on [app-name]_ which is the desired outcome. It seems if I used _&message=_ query string parameter it will make it a post, but when I used _&comment=_ parameter it added it as an activity. The problem now is getting a feed of all the _comments_ added through that particular **Discuss** action on a particular item from all users. Any ideas? – ahmed.eltawil Jun 14 '12 at 15:21