blog

JavaScript Archive at Jozef Chúťka's blog

October 4, 2013

No comments

AIR Android Facebook iOS Login Popup SSO

Facebook SSO For Flash & Mobile AIR Apps

facebooksso

This implementation is taken from TrainLord as it runs on web (flash), android and iOS (AIR) platforms. Facebook’s authentication flows are based on the OAuth 2.0 protocol. Its recommended you have general undesrtanding of OAuth protocol prior reading this article.

If you run services on your own backend (like TrainLord does), the main point of whole thing is to securely pair a facebook id and user session. So later, whenever user does a request to your backend it automatically recoginzes the facebook id. In my case I used id and name to create an unique user record in my database so I can save some more user related data (score, etc.).

Read the rest of this entry »

March 25, 2013

No comments

Haxe JavaScript JUnitReport unit tests

Unit Testing HaXe JavaScript Project

haxeunit

Today I continued to progress on my Samsung Smart TV project with unit test implementation. My aim is to prepare smooth process for automated builds. First, I tought I would struggle with it much more but at the end it appeared that necessary tools already exists.

My first sreps led me to “Writing Unit Tests” article about resources available directly with HaXe, however it seemed that JavaScript testing was not available. The article also referenced MUnit a cross-platform haxe unit testing framework, which looked to have more capabilities.

Read the rest of this entry »

November 24, 2010

2 Comments

install navigator run userAgent

Quick Tip: How to run Android application from browser?

For now I succeeded with general approach – Android market application. If you go through Publishing Your Applications you will notice there is a url (with market:// scheme) that can be used to navigate user to your application in Android market. Sadly this url works only from Android device not from desktop (404 not found)! So I came up with this code:

var isAndroid = navigator.userAgent.toLowerCase().search("android") > -1;
if(isAndroid && confirm("Do you want to run onBoard Android application?"))
    window.location = "market://details?id=air.onBoard2Android";

What it does is:

it first test user agent if it is an Android device, if so

it asks user to decide wheter to use Android and than

it redirects user into Android market application showing details of your application

From here user can install or open the application. You may try it on http://onboard.yoz.sk (run from Android device).

I was also playing with the idea about how to run my Android AIR application from browser, well normaly for AIR apps you would use install badge or its customized version in order to check if the application is installed already and then run or install it. But I hit a major problem with air.swf not dispatching Event.INIT on Android flash player :-( … I will surely get back into this to discover more.

June 3, 2010

115 Comments

Access Token Facebook facebook api FacebookOAuthGraph Graph API OAuth session

Authorizing Iframe Facebook Applications For Graph API

Facebook permission dialog requesting access to public information, email, photos and videos.

This article continues my exploration of best facebook graph api integration into your flash app. Before continue reading, make sure you understand the previous article. Due to huge interest, I am adding codes that makes your flash app working with graph api within facebook iframe. Try this app live on http://apps.facebook.com/blogoauthgraph/, notice once you get there, you are redirected to grant permissions (if not authorized or granted already) and then redirected back to the app, where you are connected and ready to use graph api.

Read the rest of this entry »

March 9, 2010

88 Comments

Facebook facebook api FBML request-form serverFbml XFBML

Inviting Friends into Facebook Application (update)

Facebook invitation dialog with a grid of selectable friends.

Those are hard times. Facebook discontinued support for Notifications.send method March 1, 2010. Calling this method returns error code 3 (Unknown method). Instead, developers are directed to use other communication channels. From those some are not yet even a part of facebook-actionscript-api yet (dashboard) other not published from facebook (invites) and those that may work via api are experimental and may change any day (activities).

Excluding streams as communication channel, the only usable way, these days, to acquire some new facebook application users is using <Fb:request-form> (part of FBML). When your application is IFrame, you may find interesting that you are able to use FBML within your HTML files. In order to make this happen, you have to use <Fb:serverFbml> (renders the FBML on a Facebook server inside an iframe). Now, lets see how to open request form in your Facebook Iframe application:

Read the rest of this entry »

February 16, 2010

No comments

base64 Bitmap ByteArray ExternalInterface PNGEncoder

Inline Images

A snapshot example showing an image data URL over colourful circles.

Have you ever heard about inline images? Inline images use the data URI scheme to embed images directly within web pages. As defined by RFC 2397, data URIs are designed to embed small data items as “immediate” data, as if they were referenced externally. This basicaly means, you can insert base64 encoded byte code of any image directly into html file. Using inline images saves HTTP requests over externally referenced objects. Data URIs can potentially store any type of data, not just images!

Read the rest of this entry »

February 12, 2010

No comments

ActionScript ExternalInterface JavaScript

Quick tip: ExternalInterface.call is synchronous!

A hand holding a red stopwatch.

It is a little wonder to me how flash player communicates with JavaScript. Calls are fully synchronous, it works as those (fp and js) were fully integrated into each other. To simulate this lets test some simple flow:

Read the rest of this entry »

February 10, 2010

4 Comments

allowscriptaccess eval ExternalInterface JavaScript

Full JavaScript Access From ActionScript (update)

Syntax-highlighted HTML showing the head element and metadata.

Have you ever tought about accessing DOM from ActionScript? In fact, you can do it and even far more. You can create and call JavaScript methods and objects, access cookies, change styles… All you need is correct AllowScriptAccess parameter within your flash object. No framework needed here, no hacks, ExternalInterface takes care.

Read the rest of this entry »

November 26, 2009

10 Comments

Authorize Facebook facebook api FBML fb_sig_session_key Redirect verifySession

Update: Facebook application missing session key on first visit

facebookAllowAccess

There are still some issues with facebook flash api vs. facebook communication. Some of them, you as an application developer, will never get into, but general user will. For example, when new user comes into your facebook iframe flash application for a first time, the first thing he see is “Allow Access?” window:

Read the rest of this entry »

October 19, 2009

25 Comments

api Facebook facebook api JavaScript solution

FB.Connect.showPermissionDialog

Facebook dialog requesting permission to publish posts to a user’s feed.

If your facebook iframe applications need extra permissions granted, you can use Facebook JavaScript Api to generate modal window over your content to request permissions from users. For this purpose I created a simple FB_test_perm() function. It takes 4 arguments:

api_key – your application api key

xd_receiver – path to xd_receiver.htm file (Cross-Domain Receiver Page)

permission – publish_stream, read_stream …

callback – your function with boolean return (true if permission granted, false if not granted)

Read the rest of this entry »

« Older Entries