{"id":943,"date":"2010-04-01T16:54:48","date_gmt":"2010-04-01T15:54:48","guid":{"rendered":"http:\/\/alittleb.it\/?p=943"},"modified":"2010-04-02T08:59:33","modified_gmt":"2010-04-02T07:59:33","slug":"consigli-di-programmazione-per-la-tua-applicazione-facebook","status":"publish","type":"post","link":"https:\/\/www.alittleb.it\/it\/actionscript-it\/consigli-di-programmazione-per-la-tua-applicazione-facebook\/","title":{"rendered":"Consigli di Programmazione per la tua applicazione Facebook"},"content":{"rendered":"<p style=\"text-align: center;\">L&#8217;articolo \u00e8 disponibile solo in inglese, ci scusiamo per il disagio.<\/p>\n<hr \/>\n<p>Today we would like to spend some time talking about our experience developing a simple Flash game for Facebook and share some useful tips with you.<br \/>\nObviously, the first thing you need is an idea&#8230;if you want your application to became famous going social you got to stop thinking like a developer and start thinking like a facebook user.<br \/>\n<!--more--><br \/>\nIndividual preferences on what kind of game a person would like to play are not as relevant as the fact your game has to have a large social component.<br \/>\nThe player is primarily a social network user and secondarily a game player; he&#8217;s using your application because he decided to join Facebook to keep in contact with friends, coworkers, relatives and share contents with them.<\/p>\n<p>Take your time and find a funny way to entertain users giving them the chance to interact with the others, telling they&#8217;re having fun playing your game and inviting friends to do the same. This way your game will spread.<\/p>\n<p>If you have decided to use Flex as development platform, keep reading, otherwise go <a href=\"http:\/\/wiki.developers.facebook.com\/index.php\/User:Client_Libraries\" target=\"_blank\">here<\/a> and choose yours.<br \/>\nYou can download <a href=\"http:\/\/code.google.com\/p\/facebook-actionscript-api\/\" target=\"_blank\">here<\/a> the official API Libraries which are fully supported by Facebook and Adobe.<br \/>\nIf you use SVN you can check them out from <a href=\"http:\/\/facebook-actionscript-api.googlecode.com\/svn\/trunk\" target=\"_blank\">this repository<\/a>.<br \/>\nIt comes with some useful example projects.<br \/>\nAlso the <a href=\"http:\/\/www.adobe.com\/devnet\/facebook\/\" target=\"_blank\">Adobe website<\/a> has some useful resoursces.<\/p>\n<p>Now you have to set up your brand new application, going here: <a href=\"http:\/\/www.facebook.com\/developers\/\" target=\"_blank\">http:\/\/www.facebook.com\/developers\/<\/a><\/p>\n<p>Once you joined the developers group and registered your application, to start testing from Flex you&#8217;d like set the &#8220;Application Type&#8221; as Desktop, so the debugging process will be easier.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"Facebook-new-app\" src=\"http:\/\/alittleb.it\/wp-content\/uploads\/post\/facebook-newapp-1.png\" alt=\"\" width=\"700\" height=\"250\" \/><\/p>\n<p>When your application is finished, you&#8217;ll decide to use IFrame or Fbml, for now let&#8217;s see how Fbml works.<br \/>\nLeave the Canvar Callback Url&#8217;s field empty, it will be read as &#8220;localhost&#8221;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"facebook-new-app\" src=\"http:\/\/alittleb.it\/wp-content\/uploads\/post\/facebook-newapp-2.png\" alt=\"\" width=\"700\" height=\"500\" \/><\/p>\n<p><strong>First step: Log In from your application<\/strong><\/p>\n<p>Create a New Flex Project and import the Facebook SWC Library ( http:\/\/facebook-actionscript-api.googlecode.com\/files\/Facebook_library_v3.4_flash.swc ).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"Facebook-new-app\" src=\"http:\/\/alittleb.it\/wp-content\/uploads\/post\/facebook-newapp-3.png\" alt=\"\" width=\"257\" height=\"113\" \/><\/p>\n<p>Then try this snippet, provided by Adobe, replacing  &#8220;xxxx&#8221; with your Application Secret and API Key (they&#8217;re stored in Your Application&#8217;s Home Page):<\/p>\n<pre>\n\n<div class=\"codecolorer-container actionscript3 mac-classic\" style=\"overflow:auto;white-space:nowrap;width:608px;height:300px;\"><div class=\"actionscript3 codecolorer\"><span class=\"kw1\">import<\/span> com<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">.<\/span>Facebook<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">import<\/span> com<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">.<\/span>events<span class=\"sy0\">.<\/span>FacebookEvent<span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> _book<span class=\"sy0\">:<\/span>Facebook<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> _session<span class=\"sy0\">:<\/span>FacebookSessionUtil<span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> API_KEY<span class=\"sy0\">:<\/span><a href=\"http:\/\/www.google.com\/search?q=string%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:string.html\"><span class=\"kw5\">String<\/span><\/a> = <span class=\"st0\">&quot;xxxx&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> SECRET_KEY<span class=\"sy0\">:<\/span><a href=\"http:\/\/www.google.com\/search?q=string%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:string.html\"><span class=\"kw5\">String<\/span><\/a> = <span class=\"st0\">&quot;xxxx&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw3\">function<\/span> <span class=\"kw7\">init<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/create a new Facebook Session<\/span><br \/>\n&nbsp; &nbsp; _session=<span class=\"kw1\">new<\/span> FacebookSessionUtil<span class=\"br0\">&#40;<\/span>API_KEY<span class=\"sy0\">,<\/span> SECRET_KEY<span class=\"sy0\">,<\/span> <span class=\"kw7\">loaderInfo<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/add listener for the connection complete<\/span><br \/>\n&nbsp; &nbsp; _session<span class=\"sy0\">.<\/span><span class=\"kw7\">addEventListener<\/span><span class=\"br0\">&#40;<\/span>FacebookEvent<span class=\"sy0\">.<\/span><span class=\"kw8\">CONNECT<\/span><span class=\"sy0\">,<\/span> onConnect<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/connect<\/span><br \/>\n&nbsp; &nbsp; _fbook=_session<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw3\">function<\/span> onConnect<span class=\"br0\">&#40;<\/span>e<span class=\"sy0\">:<\/span>FacebookEvent<span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/you're logged in!<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw7\">trace<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;Facebook API Ready&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw3\">function<\/span> doneLoggingIn<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/validate session<\/span><br \/>\n&nbsp; &nbsp; _session<span class=\"sy0\">.<\/span>validateLogin<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><\/div><\/div>\n\n<\/pre>\n<p>You can find your app information in its facebook profile:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"facebook-new-app\" src=\"http:\/\/alittleb.it\/wp-content\/uploads\/post\/facebook-newapp-4.png\" alt=\"\" width=\"583\" height=\"350\" \/><\/p>\n<p>A pop-up should open and ask you to log in, if you haven\u2019t already logged in.<\/p>\n<p>Now that you&#8217;re logged in, you might be interested in knowing how to retrieve users&#8217; data.<br \/>\nThere are several ways to access users information: the most common are API methods and FQL queries.<br \/>\nI personally prefer the latter, since I reckon it is considerably faster.<br \/>\nIt&#8217;s because you can use specific requests to get just the data you need. In fact most of the methods implemented by the API Libraries are generally wrappers for FQL Queries.<br \/>\nFQL allows you to use a SQL-style interface to construct queries that returns data stored in <a href=\"http:\/\/wiki.developers.facebook.com\/index.php\/FQL_Tables\" target=\"_blank\">these tables<\/a>.<br \/>\nIf you&#8217;re not familiar with SQL language here you can find detailed information about creating <a href=\"http:\/\/wiki.developers.facebook.com\/index.php\/FQL \" target=\"_blank\">Fql queries<\/a>.<\/p>\n<p>Here&#8217;s an example that shows how to retrieve friends&#8217; Uids, first name and last name from logged user&#8217;s Uid:<\/p>\n<pre>\n\n<div class=\"codecolorer-container actionscript3 mac-classic\" style=\"overflow:auto;white-space:nowrap;width:608px;height:300px;\"><div class=\"actionscript3 codecolorer\"><span class=\"kw1\">import<\/span> com<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">.<\/span>Facebook<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">import<\/span> com<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">.<\/span>commands<span class=\"sy0\">.<\/span>fql<span class=\"sy0\">.<\/span>FqlQuery<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">import<\/span> com<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">.<\/span><span class=\"kw7\">data<\/span><span class=\"sy0\">.<\/span>FacebookData<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">import<\/span> com<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">.<\/span>events<span class=\"sy0\">.<\/span>FacebookEvent<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">import<\/span> com<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">.<\/span>net<span class=\"sy0\">.<\/span>FacebookCall<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">import<\/span> com<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">.<\/span>utils<span class=\"sy0\">.<\/span>FacebookSessionUtil<span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> _fbook<span class=\"sy0\">:<\/span>Facebook<span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> _session<span class=\"sy0\">:<\/span>FacebookSessionUtil<span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> API_KEY<span class=\"sy0\">:<\/span><a href=\"http:\/\/www.google.com\/search?q=string%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:string.html\"><span class=\"kw5\">String<\/span><\/a> = <span class=\"st0\">&quot;xxxx&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw2\">var<\/span> SECRET_KEY<span class=\"sy0\">:<\/span><a href=\"http:\/\/www.google.com\/search?q=string%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:string.html\"><span class=\"kw5\">String<\/span><\/a> = <span class=\"st0\">&quot;xxxx&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw3\">function<\/span> <span class=\"kw7\">init<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; _session=<span class=\"kw1\">new<\/span> FacebookSessionUtil<span class=\"br0\">&#40;<\/span>API_KEY<span class=\"sy0\">,<\/span> SECRET_KEY<span class=\"sy0\">,<\/span> <span class=\"kw7\">loaderInfo<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; _session<span class=\"sy0\">.<\/span><span class=\"kw7\">addEventListener<\/span><span class=\"br0\">&#40;<\/span>FacebookEvent<span class=\"sy0\">.<\/span><span class=\"kw8\">CONNECT<\/span><span class=\"sy0\">,<\/span> onConnect<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; _fbook=session<span class=\"sy0\">.<\/span>facebook<span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw3\">function<\/span> doneLoggingIn<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; session<span class=\"sy0\">.<\/span>validateLogin<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw3\">function<\/span> onConnected<span class=\"br0\">&#40;<\/span>e<span class=\"sy0\">:<\/span>FacebookEvent<span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; _session<span class=\"sy0\">.<\/span><span class=\"kw7\">removeEventListener<\/span><span class=\"br0\">&#40;<\/span>FacebookEvent<span class=\"sy0\">.<\/span><span class=\"kw8\">CONNECT<\/span><span class=\"sy0\">,<\/span> onConnected<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw7\">trace<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;Facebook API Ready&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span>e<span class=\"sy0\">.<\/span><span class=\"kw7\">error<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ catch errors<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw7\">trace<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;ERROR:&quot;<\/span> &nbsp;<span class=\"sy0\">+<\/span> &nbsp;e<span class=\"sy0\">.<\/span><span class=\"kw7\">error<\/span><span class=\"sy0\">.<\/span>errorMsg <span class=\"sy0\">+<\/span> e<span class=\"sy0\">.<\/span><span class=\"kw7\">error<\/span><span class=\"sy0\">.<\/span>errorCode<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"kw1\">else<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw2\">var<\/span> _loggedUserUid<span class=\"sy0\">:<\/span> Int = _fbook<span class=\"sy0\">.<\/span>uid <span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <span class=\"co1\">\/\/ save logged user's IUD necessary to do the query<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/create an Fql Multiquery using user (http:\/\/wiki.developers.facebook.com\/index.php\/User_%28FQL%29)<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/and friend (http:\/\/wiki.developers.facebook.com\/index.php\/Friend_%28FQL%29) tables<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw2\">var<\/span> query<span class=\"sy0\">:<\/span> <a href=\"http:\/\/www.google.com\/search?q=string%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:string.html\"><span class=\"kw5\">String<\/span><\/a> = &nbsp;<span class=\"st0\">&quot;SELECT uid, first_name, last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = &quot;<\/span> <span class=\"sy0\">+<\/span> _loggedUserUid <span class=\"sy0\">+<\/span> <span class=\"st0\">&quot;)&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/create a FacebookCall and use post method to do a query to Facebook server<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw2\">var<\/span> fbquery<span class=\"sy0\">:<\/span>FacebookCall = &nbsp;_fbook<span class=\"sy0\">.<\/span>post<span class=\"br0\">&#40;<\/span><span class=\"kw1\">new<\/span> FqlQuery<span class=\"br0\">&#40;<\/span>query<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/add a listener for the event complete<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; fbquery<span class=\"sy0\">.<\/span><span class=\"kw7\">addEventListener<\/span><span class=\"br0\">&#40;<\/span>FacebookEvent<span class=\"sy0\">.<\/span><span class=\"kw8\">COMPLETE<\/span><span class=\"sy0\">,<\/span> onGetData<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw3\">function<\/span> onGetData<span class=\"br0\">&#40;<\/span>e<span class=\"sy0\">:<\/span>FacebookEvent<span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span>e<span class=\"sy0\">.<\/span>success<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/save your data as FacebookData<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw2\">var<\/span> <span class=\"kw7\">data<\/span><span class=\"sy0\">:<\/span>FacebookData = e<span class=\"sy0\">.<\/span><span class=\"kw7\">data<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/and store your query result as XML<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw2\">var<\/span> result<span class=\"sy0\">:<\/span><a href=\"http:\/\/www.google.com\/search?q=xml%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:xml.html\"><span class=\"kw5\">XML<\/span><\/a> = <span class=\"kw1\">new<\/span> <a href=\"http:\/\/www.google.com\/search?q=xml%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:xml.html\"><span class=\"kw5\">XML<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"kw7\">data<\/span><span class=\"sy0\">.<\/span>rawResult<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/now you can parse your XML how you're used to do<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"kw1\">else<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ catch errors<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw7\">trace<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;ERROR:&quot;<\/span> &nbsp;<span class=\"sy0\">+<\/span> &nbsp;e<span class=\"sy0\">.<\/span><span class=\"kw7\">error<\/span><span class=\"sy0\">.<\/span>errorCode <span class=\"sy0\">+<\/span> e<span class=\"sy0\">.<\/span><span class=\"kw7\">error<\/span><span class=\"sy0\">.<\/span>errorMsg<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n\n<\/pre>\n<p>Yeah, you know who you (and your friends) are!<br \/>\nAnother useful tip to create a viral application is to let users post messages to walls ( their own or their friends&#8217;), but we&#8217;ll discuss this topic in a future <a href=\"http:\/\/alittleb.it\/coding\/open-a-facebook-popup-using-actionscript-3-0\/\" target=\"_blank\">post<\/a>.<br \/>\nFor my application I decided not to use a html button to open &#8220;Invite Friends page&#8221;, I prefer having a flash button embedded in the swf.\u00a0In order to make it work I had to link it to a simple PHP script via ActionScript.<\/p>\n<pre>\n\n<div class=\"codecolorer-container php mac-classic\" style=\"overflow:auto;white-space:nowrap;width:608px;\"><div class=\"php codecolorer\">require_frame<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"re0\">$user<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$facebook<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">require_login<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/ Prepare the invitation text that all invited users will receive.<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$content<\/span> <span class=\"sy0\">=<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot; &nbsp;write something &lt;a href=&quot;<\/span><span class=\"st0\">&quot;&gt;&quot;<\/span><span class=\"sy0\">.<\/span><span class=\"re0\">$app_name<\/span><span class=\"sy0\">.<\/span><span class=\"st0\">&quot;&lt;\/a&gt;.<span class=\"es1\">\\n<\/span>&quot;<\/span><span class=\"sy0\">.<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;get_add_url().&quot;<\/span><span class=\"st0\">&quot; label=&quot;<\/span>Get Stats Now<span class=\"st0\">&quot;\/&gt;&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"sy1\">?&gt;<\/span><\/div><\/div>\n\n<\/pre>\n<p>This is the AS3 code for the button:<\/p>\n<pre>\n\n<div class=\"codecolorer-container actionscript3 mac-classic\" style=\"overflow:auto;white-space:nowrap;width:608px;\"><div class=\"actionscript3 codecolorer\">inviteBtn<span class=\"sy0\">.<\/span><span class=\"kw7\">addEventListener<\/span><span class=\"br0\">&#40;<\/span><a href=\"http:\/\/www.google.com\/search?q=mouseevent%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:mouseevent.html\"><span class=\"kw5\">MouseEvent<\/span><\/a><span class=\"sy0\">.<\/span>Click<span class=\"sy0\">,<\/span> invite<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">private<\/span> <span class=\"kw3\">function<\/span> invite<span class=\"br0\">&#40;<\/span>e<span class=\"sy0\">:<\/span><a href=\"http:\/\/www.google.com\/search?q=mouseevent%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:mouseevent.html\"><span class=\"kw5\">MouseEvent<\/span><\/a><span class=\"br0\">&#41;<\/span><span class=\"sy0\">:<\/span><span class=\"kw1\">void<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/the url where php script is stored<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">var<\/span> <span class=\"kw7\">url<\/span><span class=\"sy0\">:<\/span><a href=\"http:\/\/www.google.com\/search?q=string%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:string.html\"><span class=\"kw5\">String<\/span><\/a> = <span class=\"st0\">&quot;www.yoursite.com\/invite.php&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/create a URLRequest and use navigateToURL to link the page<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">var<\/span> request<span class=\"sy0\">:<\/span><a href=\"http:\/\/www.google.com\/search?q=urlrequest%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:urlrequest.html\"><span class=\"kw5\">URLRequest<\/span><\/a> = <span class=\"kw1\">new<\/span> <a href=\"http:\/\/www.google.com\/search?q=urlrequest%20inurl:http:\/\/livedocs.adobe.com\/flex\/201\/langref\/%20inurl:urlrequest.html\"><span class=\"kw5\">URLRequest<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"kw7\">url<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw7\">navigateToURL<\/span><span class=\"br0\">&#40;<\/span>request<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>L&#8217;articolo \u00e8 disponibile solo in inglese, ci scusiamo per il disagio. Today we would like to spend some time talking about our experience developing a simple Flash game for Facebook [&hellip;]<\/p>\n<p><a href=\"https:\/\/www.alittleb.it\/it\/actionscript-it\/consigli-di-programmazione-per-la-tua-applicazione-facebook\/\" class=\"more-link style2-button\">Read More<\/a><\/p>","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[79,81,80],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/posts\/943"}],"collection":[{"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/comments?post=943"}],"version-history":[{"count":0,"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/posts\/943\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/media?parent=943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/categories?post=943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.alittleb.it\/it\/wp-json\/wp\/v2\/tags?post=943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}