(Freshplanet Facebook-ANE) How to make the login screen in-app - facebook

I am currently using the Freshplanet Facebook-ANE and was wondering about something that is bugging me currently.
I want to implement a simple post to wall feature inside my app, and this ANE does exactly what I want, except for one thing. When I do the actual post to wall dialog, it pops up just like I want it, in a WebView inside my app. The login takes me to Safari or the Facebook app if I have it installed, which is what I want to avoid.
Here's the line I'm using to open the session :
Facebook.getInstance().openSessionWithPublishPermissions(POST_PERMISSIONS, OnSessionOpened, true);
That works perfectly for posting, but takes me outside of the app.
I've tried using the same .dialog() function I use for the post, and it worked, but I can't seem to post to the wall afterwards (maybe I'm not correctly catching the access token or something)
Any help would be appreciated. I believe I've set up everything correctly on my Facebook App page, and that my AS3 project is correctly setup.
Thanks for the help !

If you want to strictly stay into the app, you must use StageWebView. It's something like a wrapper of HTML page inside Flash.
First check if you are logged in (this is code from Facebook.as of FreshPlanet):
/** True if a Facebook session is open, false otherwise. */
public function get isSessionOpen() : Boolean
{
if (!isSupported) return false;
return _context.call('isSessionOpen');
}
If there is no session - start the web view. Otherwise - continue as usual.
You have to keep in mind that StageWebView is pretty.. how to say it.. bad is the kindest thing I could say :) You must implement your own close button, listen for url changing, etc.
You could look into Facebook AS3 SDK, which at least has some kind of 'platform' for the web view..
Good luck!

Related

Open link in browser or open app

I have made an iphone app. The app calls the webpage and displays the content. Server side coding is in php. The problem is I have several links in the webpage. When I click on the link in the webpage it opens the entire page and I am no longer able to go back to where I was.
I tried iframe but not all the website support it like google, facebook. What I am looking is someway to open the link in browser or launch the another app, like the app of facebook. I have quite thoroughly searched for the solution without much luck.
Any pointers would be greatly appreciated.
Thanks
To implement navigation for UIWebView you can do the following: create two buttons, one for going forward in history and one for going back. And here is the code for that buttons you must include:
//For going forward
if (yourWebView.canGoForward)
{
yourWebView.goForward();
}
//For going back
if (yourWebView.canGoBack)
{
yourWebView.goBack();
}

redirect on facebook app install

Upon install of my app on a Facebook Page, I'd like to send the user to an URL with further instructions. I'm starting the installation with http://facebook.com/add.php?api_key=app_api_key&page=page_id, which installs but redirects the user to the Facebook Page itself. It seems like various forms of redirect were available at some point:
Post-authorize callback URL. I can no longer find that in App settings.
The next parameter for add.php. I can't seem to get this to work
I have seen some apps that do redirect upon install, so I believe this is possible. Maybe it's using an old Post-authorize setting that's no longer visible?
Any help or point would be greatly appreciated! I'm also not attached to using add.php, if there's a Facebook Connect method that does this I'd use that instead (I'm looking at profile.addtab though that doesn't seem to work either).
You can set the redirect URL in the app properties. You can no longer set it from the developer control panel in Facebook, but you can still set it using the REST api.
The list of app properties is here: http://developers.facebook.com/docs/appproperties/
To set the "post_authorize_redirect_url" you would use something like this:
https://api.facebook.com/method/admin.setAppProperties?
access_token=CURRENTTOKEN&
properties={'post_authorize_redirect_url':'http://mydomain.com/post_authorize_folder/'}
I am not completely clear on this, but I believe the url needs to point to a folder, terminated with "/" rather than a specific file.
The callback gets two parameters:
installed = 1 (true)
fb_page_id = the page id when your app was installed
First page that Canvas is point to should have
< script type='text/javascript'>top.location.href = 'REDIRECT-URL';< /script>
So when your app is opened it will automaticaly redirect to REDIRECT-URL
I'm not sure that you can avoid opening of application canvas page after installing application.

titanium webview - go to default browser when clicking links

in titanium, i'm using the webview to display a wordpress blog page, that is already formatted for mobile browser. instead of writing my own interface, this works as a good work around. the apps sole focus isn't the browser.
but my issue lies, when the user clicks a link outside of the initial displayed domain. i only want the main domain to be displayed in the apps browser. if any other link is clicked, that takes the user outside of that domain, i want to have it open in the phones default browser.
can anyone point me in a direction for this. i tried adding a listener to try and catch link clicks, however, i've been unsuccessful.
thanks
in this blog posting I show how to find links in a webpage and change the link behavior. Using the same method, you can intercept the links and redirect to opening the URL in the devices default browser
One solution would be to catch the onclick() Event by Javascript inside the WebView (your blog code) and handle this by a custom handler. Maybe you can inject the javascript event handler code into the running WebView through Titanium.
Another solution is to make your blogposts readable for app technology and create a new data interface. This is the way I would do. For that I would use some kind of JSON data format and a simple REST Interface to get the data.
I don't think bove solutions are that simple. If you want an app with "great feeling", you'll have to handle the events by your own. Maybe Phonegap would be a better solution four your problem. But there you will still need a kind of REST/JSON interface for your blog data. The idea behind an app is, that the main code is in your app and you get the content from a remote source. This way you'll get an advantage compared to a simple browser optimized site.

How To stream.publish Within a Profile Tab

I have successfully setup an iFrame based App using the Javascript SDK, and we are trying to enable it on a Page Tab.
It seems Facebook has changed some things lately, because the app breaks when added to the Page Tab. I even went as far as making sure that all external scripts were included in the main index.php file, and that the body tags were taken out.
No, I'm trying to find out if it is even possible to use methods such as the stream.publish within a Profile Tab at all.
It seems like it isn't. As far as I can tell, you can no longer use any social methods on the Profile Tab.
Here were two related articles on the subject:
insidefacebook.com/2010/08/19/facebook-moving-toward-iframes-over-fbml-for-canvas-apps-and-page-tabs/
-and-
developers.facebook.com/roadmap
If anyone can confirm or deny this, it would be a huge help. The Facebook docs are just all over the place.
Here's a link to the working App Canvas as it stands now: http://apps.facebook.com/votetesting/
I know that on tab pages, you cannot do any JS until the user clicks on something first. Maybe that is the problem.
-Roozbeh

Need facebook logout if user logout from my application

In my joomla application I am facing a problem . user can log in my application through facebook ,but I want whenever user log out from my application, it must be log out from facebook account too.
Please give me your suggestion or any idea how can i do this?
Thanks
I assume you're using Facebook Connect?
If so, just do the following in JavaScript:
FB.Connect.logout(); // old JS API
FB.logout(); // new JS API
http://developers.facebook.com/docs/reference/javascript/FB.logout
http://developers.facebook.com/docs/reference/oldjavascript/FB.Connect.logout
Are you redirecting to another page along with or immediately after the FB.logout call?
I have found that FF and Chrome will execute the FB.logout call quickly enough for this to work properly but that IE and mobile browsers (because of network speed in addition to differences in the JavaScript engine) will not complete the call successfully before the browser loads whatever page you're redirecting to.
So, the safest thing is to put any redirect into a callback function and pass that to FB.logout like this:
function mysignout(url)
{
FB.logout(function()
{
top.location.href = 'url'
});
}
I was originally putting FB.logout directly in the onclick event of an anchor link and while that worked in FF and Chrome it did not work in IE or in my Android browser. Doing the above made it work in all environments.
Surprisingly, it take 2+ seconds for FB.logout to completely successfully in most environments. There is obviously some kind of ajax call involved to revoke authentication on the server, not just destroying the local cookie.