I haven't personally done Facebook development, but my understanding from talking to FB developers is that FB provides a mechanism where, within a FB application, you can create a link with a URL like:
<a href="http://facebook.com/yourapp/some/path">Click here</a>
and FB will:
1. Sign the request
2. Pass it along to http://yourapp.com/some/path (assuming you've associated the app name "yourapp" with "yourapp.com"
3. Pass the response to your application.
Another option is to build all of the view logic in the assets uploaded to Jive and only use osapi.http.get calls to get JSON data, but rebuilding the interface from scratch isn't very appealing considering a lot of the work has already been done on the server side.
Jive opensocial container being a OAuth 2.0 consumer, close to the end of this documentation there is information that shows you how you can use website APIs that implement OAuth 2.0 in a Jive application. The example there is actually referring to facebook. There is also an attachment facebook.xml which is a working Jive app that uses Facebook APIs.
If your application doesn't want to use osapi.http.get/post to make API calls to facebook but rather just display views building the content on the serverside, then your application server has to manage authorizing user with facebook and also saving the access token. If can also be a combination of both, meaning once you application fetches the json data it can send that data to your server for rendering the view.
I apologize - I was unclear. I was just using Facebooks capabilities as an example, but I don't actually need to communicate with Facebook.
Here's what I want to achieve:
I have several pages on my website (roundpegg.com) that all contain user-specific data. I would like to show that data in my Jive app.
When the Jive app loads, I would like to show an index page that links to each page.
However, normal links won't work because they are not signed by Jive (so I don't know which user information to display).
What I think I want to do is just change the links to have hrefs like "http://apphosting.jivesoftware.com/apps/roundpegg/example" and have it sign the request, hit "http://roundpegg.com/example" and return the result to my application. If I'm not mistaken, FB has a similar mechanism.
Besides the osapi.http and io.makeRequest, the only other way to have requests to an external server be signed is using
One suggestion would be when your server receives this request which includes the signature from Jive, your server can attach a signature (that you can validate) to the links plus the user info.
Thanks for the information. I appreciate it.
I thought about using different views ('home', 'default') with the href argument, but unfortunately, I need to display many different pages within each view. I also considered using subviews (e.g. 'default.page1', 'default.page2') but I found that I could not use an external URL with a subview.
"One suggestion would be when your server receives this request which includes the signature from Jive, your server can attach a signature (that you can validate) to the links plus the user info."
Yes, that would work. Thanks for the idea - I may end up doing just that.
To summarize for everyone reading this, the options for displaying multiple pages within one view are:
2. Rewrite all links with some sort of session ID
I tried to get a nested iframe solution working but didn't have any luck (I tried using this library
https://github.com/cowboy/jquery-postmessage/). It worked with browsers that support the postMessage call, but I couldn't get the "legacy" mode (for browsers like IE7) to work within the OpenSocial container. If anyone has any luck with this approach, please let me know.
The motivation for the nested iframe is this: if I could place an iframe that talks to my server within my gadget, then I could just display content from my server and have working cookies, relative URLs, etc. I need cross-iframe communication to the iframe that displays my server's content can ask the "parent" iframe to get/post info in Jive.
On a related note, I noticed in this article:
https://developers.jivesoftware.com/community/docs/DOC-1119 that an external server can update activity streams and status messages. Does the Gateway API support other operations (such as getting friends) as well?
If discovered any best practices that make gadget development easier, I'd very much appreciate hearing about them. Thanks!
Have you looked at OpenSocial's Preload capability?
In the application definition, you put in something like...
<Preload authz="oauth" href="http://localhost:9090/oauth-provider/echo" /> (this is from the OAuth example.)
When you do the make request, the results are already available to you. My thinking here, and maybe I'm out in left field, is that you could preload the URLs you want, then inside the gadget, issue the necessary makeRequest calls. Since these are already available, no call is actually made and the data should be returned.
Thanks very much for the suggestion.
I hadn't looked in detail at the Preload capability, but in this particular case, I don't think it's a good fit.
First of all, some of the results I need are dynamic. For instance, I need to display a chart of data, but this data will be updated depending on the users actions in the application. From my understanding, the Preload call would load this data once and then just display the preloaded results.
I recently found this blog post and although it's a bit old, it describes some of the challenges I've run into as well as ideas for solutions (http://www.metablocks.com/blog/2009/03/20/opensocial-developer/).
Agree that preload doesn't seem to fit if you've got dynamic data. If I were to summarize what you are trying to do, it would be that you'd like to have all requests go through the Jive proxy, so they can be signed, but not through makeRequest. Is that right?
Just wanted to make sure I understand your note above. You are not able to do something like the subveiew:
<Content view="home.subview1" href="hello.html"></Content>
Is this correct?
Will you try this? I just ran this in the app sandbox and it worked for me. Application def is here:
<?xml version="1.0" encoding="UTF-8"?>
<Require feature="views" />
<Require feature="dynamic-height" />
<Content type="html" view="home">
gadgets.views.requestNavigateTo( new gadgets.views.View( 'canvas' ) );
gadgets.views.requestNavigateTo( new gadgets.views.View( 'canvas.sub' ) );
<p><input type="button" value="Switch To Canvas View" onclick="switchViews(); return true;"/></p>
<p><input type="button" value="Switch To Sub-Canvas View" onclick="switchViewsSub(); return true;"/></p>
<Content type="html" view="canvas" >
<Content view="canvas.sub" href="canvas.html" />
© Copyright 2000–2010 Jive Software. All rights reserved.