I'm developing an app which has a Content Action and an !app Action.
I would like to get via javascript (i.e. Open Social API I suposse...) the current user (I got it!) and the current blog post (blogpost id) from both actions.
Is it possible?
Thank you!
I found it!
You can do it adding an gadgets.util.registerOnLoadHandler() listener, and inside it you should call the osapi.jive.core.container.getLaunchContext(function (selection) {});
From selection object you can get the type and the id:
var type = selection.jive.content.type;
var contentid = selection.jive.content.id
You have a full example from Jive Developers Website
Related
I recently made a fanpage and i have used embedded code from one of the post of my fanpage to my website.
So now It shows the post on my website and number of likes but i would like to show current existing comments which that particular post had got. Right now it is just displays the comment button and if i will click that then it will take me to the fanpage just for the sake of comment.
So heres what i need
1 - Comment on the embedded post without leaving the website to facebook.
2 - Displaying all the current existed comments ..
the image right now look like this
Thats very simple. First, you need to login user and ask for publish_stream permission. After the user is logged in, you just to display a button that triggers the function named comment, passing the ID (corresponding to the object user is going to comment to) .
You will also need an input field for inserting the comment (of course), and using jquery .value we will get the value of the input field .
PS: Specify NAME and ID on the message input field. I dont remember wich one is, put both of them .
After getting the variables, we will call FB.api, specifing the variables id and comentario than get the response for handling the result (if you want), you can try to reload the comment plugin, or refreshing the page .
function comment(id) {
var id = id;
var comentario = document.getElementById("message").value;
FB.api("/"+id+"/comments","POST",
{
"message": comentario
},
function (response) {
if (response && !response.error) {
alert('Comentado !');
} else {
alert('Erro !');
}
});
$("#atividade").html('COMENTADO');
}
That is very simple and fun, but you will need to get authorization from facebook platform to ask users for publish_stream permissions before production .
I think David's answer will just post a new comment, not show all post's comments.
Unfortunately there is not a option to show the comments on embed posts.
You need to get the post id, call a api to load all comments and so embed each one of them. Yeah, that's terrible...
Open the graph api explorer:
https://developers.facebook.com/tools/explorer/
Type {post-id}/comments on GET input and send it to see a response example.
And that's how you embed comments:
https://developers.facebook.com/docs/plugins/embedded-comments
I don't think loading all comments from all posts will have a good performance. I suggest you to create a button "see comments" which call the api. After that you can create the input text for new comments, like David said.
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]&method=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.
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.
Just a quick question to make sure i'm on track -
I've started supporting a ready FB app.
Yesterday the client reported an issue with a part of the app which uses the fb JS SDK notification plugin.
In the callback the code refers to (this is only the callback of the entire FB.io):
}, function(res) {
if(typeof(res)!='undefined' && res != null){ // if user invited friends
var ids = res.request_ids.toString();
but when I console.log the res object, there is no res.request_ids - onlt res.request and res.to (which contains the IDs).
Can it be that Facebook changed the response object? I could find the official docs which say that i'm correct about the object - there are 'request' and 'to' properties, no request_ids - but why would it work till now? was there a change in the response object? is there a place where these changes are published in advance in order to prevent downtime?
Thanks...
"Can it be that Facebook changed the response object?"
Yes, they announced the change February of last year. http://developers.facebook.com/blog/post/464/
"*I could fin"d the official docs which say that i'm correct about the object - there are 'request' and 'to' properties, no request_ids - but why would it work till now?*"
Official documents:
https://developers.facebook.com/docs/reference/dialogs/requests/
http://developers.facebook.com/docs/channels/#requests
"Was there a change in the response object?"
Yes, see: http://developers.facebook.com/blog/post/464/
"is there a place where these changes are published in advance in order to prevent downtime? Thanks..."
Yes, you will want to read their developers blog at: http://developers.facebook.com/blog
For some time now I try to figure out how these guys were able to add "Sign online here" button which is "install App" button on their fan-page tab:
http://www.facebook.com/GuinnessIreland?v=app_165491161181
I've read around the web and couldn't come up with any solid solution. The FBML and FBJS documentation left me with nothing.
So please, if anyone can help me with this.
NOTE: To make multiple tests on the Ajax request that are sent, do not accept the App install. It behaves differently after that.
I had some problems with finding out about it as well. There is no info about this kind of behavior in wiki or anywhere. I got it working after trying some possible solutions and the simplest one is to make user interact with content embedded in fan page tab such as click on something etc. Then you need to post an ajax request with requirelogin parameter to pop up to come out. The simple example would be:
user_ajax = function() {
var ajax = new Ajax();
ajax.responseType = Ajax.RAW;
ajax.requireLogin = true;
ajax.ondone = function(data) {
new Dialog(Dialog.DIALOG_POP).showMessage('Status', data, button_confirm = 'Okay');
}
var url = "http://yourappurl.com/request_handler"
ajax.post(url);
}
And the trigger for it:
Interaction
Then if user is known to be using your application (fan page tab) you can prompt him for additional permission like publish stream or email communication by calling:
Facebook.showPermissionDialog('publish_stream,email');
Hope this solves the problem.
I have some code like the following in my application:
message = "Hi, #John Doe!"
postID = fb.stream.publish(
message = loader.render_to_string('wall_post.phtml', {'message':message}),
action_links = simplejson.dumps([{'text': "Check out blah", 'href': "http://blah.dev"}]),
target_id = 'nf'
)
Is there any way to represent a facebook #mention in the message string so that facebook converts it to a profile link for the mentioned user?
I've also been looking for an answer to this. The facebook website uses the format:
#[139730900025:PhotoGrabber] is awesome
to represent the links but I haven't been able to make that work. I re-posted a thread on the facebook forum under the "Stream" category since your post wasn't getting any attention:
http://forum.developers.facebook.com/viewtopic.php?id=47885
Mention it's partially available by open graph now. You can use only when posting an open graph ACTION
Check:
https://developers.facebook.com/docs/opengraph/mention_tagging/
It seems still impossible to use #mention tagging in classic feed posting via API
I'm pretty sure this is impossible at the moment. If it were posible by using the format that tam7t suggested it should work... Your best bet is asking them to add that to their api stream parser.
This is not possible at the moment, sorry.
AFAIK facebook's API does not allow this. The only approach that I know of at the moment would be to write a screen scraper to do these posts using the format described by tam7t's answer. If you use the mobile version of facebook's site (m.facebook.com) it makes it much easier.
NOTE: This might be a violation of Facebook's Application TOS.
Edit:
Here is some ruby code that will do the trick, using the Mechanize Gem
require 'mechanize'
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
page = agent.get('http://m.facebook.com')
form = page.forms.first
# enter credentials
form.pass = 'user password'
form.email = 'user#example.com'
page = agent.submit form
# go straight to page to post on
page = agent.get("http://m.facebook.com/wall.php?id=PAGE_ID_NUM")
form = page.forms.first
form.message = "#[139730900025:PhotoGrabber] is awesome"
page = agent.submit form
NOTE: Obviously (as tiagoboldt kindly pointed out) it would be wrong to store / utilise the credentials of other people in your application. This approach would only be appropriate for making posts from a facebook account that you controlled.
That said, back to the original question of putting an #mention in a wall post, I have noticed that whilst the post and #mention go up on the wall fine, this method does not propagate the post to the mentioned user/page's wall. Not sure if that is important to you.