Home  >  

Creating a Hello Friends App using ActionScript 3.0, PHP and Facebook API

Author photo
AddThis Social Bookmark Button

Welcome to our new series that will cover the techniques necessary to create advanced Facebook applications that fully utilize the Flash, PHP and the Facebook API. This is the first article of the series. Please note that every article is not independent and in order to understand, let's say article 3, you must read article 1 and 2 etc.

series badge
Find the rest of this series on the series page.

As we all know life is much more colorful with friends, Facebook is the best example on the internet for this case. It's even more colorful when you can use the Facebook API to create applications on that platform. Using Flash, PHP and the FB API we can utilize ActionScript OOP features to make the applications perform better then with standard FBML. I'm not trying to say here that FBML is bad, no, this series will try to teach how to implement existing knowledge of Flash into the Facebook application platform. Take a quick look here at my app, which uses ActionScript 3.0, PHP and Google Maps. The problem with those technologies is that the knowledge is scattered through the Web and you need a lot of patience to assemble those pieces. Fortunately, you have me. I did a lot of hard work and I will share my experience for you.

img1.png

I don't need to tell you a lot about Facebook applications. But there are more and more users who simply don't like Facebook applications because they don't really have a purpose and do not solve a real world problem. This is the issue that this series tries to address. The goal is to use ActionScript, PHP and the existing FB API to create truly useful applications that users will love and come back. That's not an easy task!

I will not talk a lot about the technologies as we want to get into the action as soon as possible. I admit that there might be better ways of to use Flash inside Facebook, but this approach proved to be successful in my previous projects, which had a few thousand users, so you want be wrong following this series.

Let's get our hands dirty!

So, let's examine all the tools we need to work on this:

1. First of all we need at least Flash CS3, you may use CS4. Because we use the core ActionScript 3.0 features there is no difference if we use CS3 or CS4.

2. We need a text editor for PHP, you can use notepad but I recommend EditPlus.You can download it here.
3. We need a FTP program to upload the files to a remote directory.
4. We need a good internet connection to test all we did directly on a web server. Unfortunately until now I never worked offline on an FB application.

What knowledge is required here?

1. A basic understanding of ActionScript, PHP and general OOP concepts.

2. Knowledge of setting up Facebook applications. There are lot of good tutorials online that cover this, like this one.

So if you've never built a Facebook application before, read the mentioned tutorial and practice a bit. This series assumes that you are already familiar with the setup of Facebook apps.

In this article, we will create a simple application that will help you gain confidence and prepare you for more complex stuff that follows. Don't expect any kind of spectacular stuff here as this is intended to get you off the ground and will serve as a basis for future apps.

Step one:
Create a new Facebook application called "FlashTest_Mirza" or choose another unique name. Select FBML as the rendering mode for the application.

You should have a screen similar to this:

img2.png
So, once this is set up, you need to open Flash C3 and create a new document size 500 x 400, like on the image below:
img3.png
You can call it main.fla. Publish the swf to get main.swf. At this time nothing will be added to the swf, later we will come back and add stuff to the swf. In your project folder you should should have main.fla and main.swf.
Open your favorite text editor and add the following code to it:
      <?php

//////////////////////////////////////////////////////////////////////
//
// main.php 
//
///////////////////////////////////////////////////////////////////////

//include facebook api etc.
require_once("pathToYourFacebookLibrary/facebook/client/facebook.php");

//create new facebook instance
$facebook = new Facebook(YOUR_KEY, YOUR_SECRET);

//prompt the user to login
$fb_user = $facebook->require_login();

//check if the user has added the app
if (!$facebook->api_client->users_isAppUser()) {
 	     //if not, redirect him to add it
              $facebook->redirect($facebook->get_add_url());
}

?>
      <!-- flash file -->
      <fb:swf swfsrc='http://www.yourServer.com/yourApp/main.swf' allowscriptaccess='always' bgcolor='#ffffff' wmode='transparent'  flashvars='' width='500' height='400'/>
    
Now, save this as main.php in your project folder. In that folder you should now have the following contents:
- main.php
- main.swf
- folder of your Facebook api library
For now there is nothing else that we need in order to get this working. Upload this to your Facebook application directory on your remote server and call the application in the Facebook applications canvas.
It should look similar to this:
img4.png
I agree that this is a modest result, but don't get impatient; we will make the application a bit more impressive. Nevertheless this is a small but very important step in the learning curve. We really need to get familiar with how the swf lives inside the Facebook application canvas. I never saw a basketball player dunk before learning the layup, so that's that same here for us.
Let's go quickly step by step through the PHP code and examine what every line of code does.
 //include facebook api etc.
        require_once("pathToYourFacebookLibrary/facebook/client/facebook.php"); 
This is something I really don't need to explain a lot, it simply includes our Facebook API library into the PHP code.
 //create new facebook instance
        $facebook = new Facebook(YOUR_KEY, YOUR_SECRET); 
This is where the fun happens. We use the Facebook class that was imported in the previous line of code to create an instance of the Facebook class using our application key and secret. With the $facebook object, we are able to perform all queries on the Facebook API to get our desired data, so don't lose it!
 //prompt the user to login
        $fb_user = $facebook->require_login(); 
The require_login method prompts the user to login to facebook if he is logged out. If somebody tries to come to your app, let's say via direct link, like http://apps.facebook.com/myapp, the user will be prompted to sign in.
As a return value, the method returns the id of the logged in user that is stored in $fb_user. The id is something like 1110516263. We can do plenty of things with that id!
The next step in this article is to get something on the screen in the swf that comes directly from Facebook. We will try to load the profile image of the logged in user and display it in the simplest way. So, how we are going to do that?
First we need to modify the PHP code. The PHP code that we have here at this stage is quite good, we just need to add one line of code and modify another one to create the desired result. The goal is:
- load the Facebook profile image
- pass with variable to the swf
- display it in Flash in the way we want it
Add the following line at the end of the script:
 //select the profile image
      $photoData = $facebook->api_client->users_getInfo($fb_user, 'pic_big'); 
We can assume what this line of code is returning the path to the image, but it's a bit trickier then you'd expect. The result that is returned is not directly the path to our profile image, it's an array. So when we iterate through the array we can see the following results:
 Array(
      [0] => Array(
      [uid] => 1110516263
      [pic_big] => http://profile.ak.facebook.com/v224/120/49/n1110516263_7773.jpg
      )
      ) 
So in order to access the profile image, we need this:
 $photoData[0]['pic_big']; 
And to make it more easy to access we make a shortcut variable:
 $photo = $photoData[0]['pic_big']; 
With that variable, we need to pass this variable to the swf the way most of us know:
      <fb:swf swfsrc='http://www.yourServer.com/yourApp/main.swf?photo=<?= $photo ?>' allowscriptaccess='always' bgcolor='#ffffff' wmode='transparent'  flashvars='' width='500' height='400'/>
    
Note the
 ...main.swf?photo=
        <?= $photo  ?>
        ... 
We do not want to get confused, so we should look at the whole PHP script after the modification:
      <?php

//////////////////////////////////////////////////////////////////////
//
// main.php 
//
///////////////////////////////////////////////////////////////////////

//include facebook api etc.
require_once("pathToYourFacebookLibrary/facebook/client/facebook.php");

//create new facebook instance
$facebook = new Facebook(YOUR_KEY, YOUR_SECRET);

//prompt the user to login
$fb_user = $facebook->require_login();

//check if the user has added the app
if (!$facebook->api_client->users_isAppUser()) {
 	//if not, redirect him to add it
             $facebook->redirect($facebook->get_add_url());
}

//select the profile image
$photoData = $facebook->api_client->users_getInfo($fb_user, 'pic_big');

$photo = $photoData[0]['pic_big'];

?>
      <!-- flash file -->
      <fb:swf swfsrc='http://www.yourServer.com/yourApp/main.swf?photo=<?= $photo ?>' allowscriptaccess='always' bgcolor='#ffffff' wmode='transparent'  flashvars='' width='500' height='400'/>
    
We need to modify the fla that we created previously to receive the variable.Once we receive it, we can do a lot of stuff in Flash since we have the freedom to create what we want.
Open up main.fla again.
Open the Components panel (Window -> Components).
Place the Loader component on the stage like shown on the image below.
img5.png
Center it on the stage. Open the property inspector and name it img_mc.
The loader itself should be placed on a layer called "Components". You can name the layer whatever you want. Create a new layer above the layer and name it Actions, as you can anticipate, this layer will hold all the ActionScript 3.0.
OK, so we have our Loader component on the stage. As you can already assume, the component will contain the profile image. Sure there are tons of other ways to display it, but for the sake of simplicity it is OK to show it this way.
Click on the first frame of the Actions layer and place the following code on it:
 //retrieve the variable sent from php
      var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
      var photoSrc:String = String(paramObj["photo"]);
      
      //display the image...
      img_mc.source = photoSrc; 
So, the final image this should look like this:
img6.png
Nice, huh? OK, don't get too comfortable. Let's make something fancy out of it!
Well, so far we have been introduced to the workflow of Flash, PHP and the FB API. With this knowledge, you will be able to approach more complex topics that follow.
So, ready for the next step. Until now we haven't seen much of Flash capabilities inside Flash. So let's extend our previous sample to make something more useful. The one thing we must always remember is that our Facebook application needs to be flashy and fancy, but if we leave out the social part out of our application we won't have much success. People do not like to be lonely and we will make our application open to our friends. :-)
So, let's extend the application to load a few friends and their current statuses, and we will let flash display it using the tween classes. The social part here is that we will keep track of the moods of our friends as the application will keep us updated. The Flash part is that we will use the Tween classes to display the data in the way regular FBML can't. I like to know what is going on with my friends so I need an application that will handle it without any clicks on Facebook. Here is the image of the final result:
img10.png
Here is the raw pseudo code for this application:
- connect to Facebook API
- load the list of friends and their statuses
- randomly select only 10 friends and statuses
- send it to swf
- populate the flash movieclips with user image and status
- apply some tween classes on the movieclips to switch between users
So when we open this application on Facebook, we will be able to sit back drink and our coffee, while we will be able to read what's going on with our friends. Ain't that fun?
We need the following Facebook api methods to call in PHP in order to accomplish this. Those methods are:
- users_getFriends (http://wiki.developers.facebook.com/index.php/Friends.get)
- users_getInfo (http://wiki.developers.facebook.com/index.php/Users.getInfo)
Here is the line of code that retrieves our our friends:
 $friends = $facebook->api_client->friends_get(); 
Here is the result that will be store in $friends:
 Array
      (
      
      [0] => 2022256
      [1] => 30811372
      [2] => 61802896
      [3] => 501579407
      [4] => 501668263
      [5] => 502578999
      [6] => 503611040
      [7] => 513106993
      .
      .
      . 
In our sample application we really do not want to pass 200 or 1,000 friend ids to Flash. We pass the variables as a query string and since query strings are limited to only 64kb characters we need to select only 10 friends and pass it to Flash. So, let's select random 10 friends from our list and display it:
Here is the code:
    $friends = $facebook->api_client->friends_get();</div>
  //calculate how many friends we have
  $friendCount = count($friends);
  
  //create a new array to store the 10 randomly selected friends
  $selFriends = array();
  
  //init the counter var
  $i = 0;
  
  //iterate 10 times
  while($i < 10){
   //pick a random friend from the list
   $random = (rand() % $friendCount);
   //add the friend to the selected friends
   array_push($selFriends, $friends[$random]);
   $i++;
   }
  
  //now simply get the profile images and statuses using the api method and the array
  $profileImages = $facebook->api_client->users_getInfo($selFriends, 'pic_big');
  $statuses = $facebook->api_client->users_getInfo($selFriends, 'status');
  
OK, now we have the images and the statuses, we can't simply send this array, we need to serialize it:
 $i = 0;
      $len = count($profileImages);
      $queryStr = "?";
      
      for($i = 0; $i < $len; $i++){
       $img = $profileImages[$i]['pic_big'];
       $status = urlencode($statuses[$i]['status']['message']);
       //concat the strings
       $queryStr .= ("image".($i + 1)."=".$img."&status".($i + 1)."=".$status."&");
       } 
The result will produce this:
 ?image1=http://profile.ak.facebook.com/v224/120/49/n1110516263_7773.jpg&status1=This is my status&image2 
So, this is the raw string we need to pass to Flash:
      <fb:swf swfsrc='http://www.yourServer.com/yourApp/main.swf<?= $queryStr ?>' allowscriptaccess='always' bgcolor='#ffffff' wmode='transparent'  flashvars='' width='500' height='400'/>
    
In order to maintain the overview, we should see the the following code at the end:
      <?php

//include facebook api etc.
require_once("pathToYourFacebookLibrary/facebook/client/facebook.php");

//create new facebook instance
$facebook = new Facebook(YOUR_KEY, YOUR_SECRET);

//propmpt the user to login
$fb_user = $facebook->require_login();

//check if the user has added the app
if (!$facebook->api_client->users_isAppUser()) {
 
 	//if not, redirect him to add it
     $facebook->redirect($facebook->get_add_url());
 
}

$friends = $facebook->api_client->friends_get();


//calculate how many friends we have
$friendCount = count($friends);

//create a new array to store the 10 randomly selected friends
$selFriends = array();

//init the counter var
$i = 0;

//iterate 10 times
while($i < 10){
 	//pick a random friend from the list
 	$random = (rand() % $friendCount);
 	//add the friend to the selected friends
 	array_push($selFriends, $friends[$random]);
 	$i++;
}

//now simply get the profile images and statuses using the api method and the array
$profileImages = $facebook->api_client->users_getInfo($selFriends, 'pic_big');
$statuses = $facebook->api_client->users_getInfo($selFriends, 'status');

$i = 0;
$len = count($profileImages);
$queryStr = "?";

for($i = 0; $i < $len; $i++){
 	$img = $profileImages[$i]['pic_big'];
 	$status = urlencode($statuses[$i]['status']['message']);
 	//concat the strings
 	$queryStr .= ("image".($i + 1)."=".$img."&status".($i + 1)."=".$status."&");
}

?>
      <fb:swf swfsrc='http://www.yourServer.com/yourApp/main.swf<?= $queryStr ?>' allowscriptaccess='always' bgcolor='#ffffff' wmode='transparent'  flashvars='' width='500' height='400'/>
    
Now it's time to work on the Flash file we created. Reopen main.fla. Select the loader component that is already placed on the stage. Right click and select "Convert to Symbol". Name it UserStatus. So, once the symbol is created double click it to enter the edit mode of the clip.
img7.png
Now, once you are there, place a text field just below the UILoader component. Name it status_txt. The UILoader must have the name img_mc.
img8.png
Now when you exit the edit mode of the UserStatus MC, you should be name the whole UserStatus clip friend_mc.
img9.png
Double-click the movie clip again. Inside the movie clip there should he one layer with all the components on it. Create one layer above and name it "Actions". Place the following script on it:
 function setImage(e:String):void{
       
       img_mc.source = e;
       
       }
      
      function setStatus(e:String):void{
       
       status_txt.text = e;
       
       } 
Now, go back to the main timeline and modify the script from the previous sample.
 import flash.utils.Timer;
      import flash.events.TimerEvent;
      import fl.transitions.Tween;
      import fl.transitions.easing.*;
      import fl.transitions.TweenEvent;
      
      //retrieve the variable sent from php
      var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
      
      var timer:Timer = new Timer(3000);
      timer.addEventListener(TimerEvent.TIMER, switchUser);
      timer.start();
      
      function switchUser(e:TimerEvent){
       var randNum:Number = Math.round(Math.random() * 6) + 1;
       friend_mc.setImage(paramObj["image" + randNum]);
       friend_mc.setStatus(paramObj["status" + randNum]);
       var aTween:Tween = new Tween(friend_mc, "alpha", Strong.easeOut, 0, 1, 3, true);
       } 
Hope you enjoyed the article. Next week we will discuss the various types of embedding swfs into the Facebook canvas along with interesting samples. See you next week!


Continue to Part 2, Overview of Embedding SWFs into Facebook Canvas

To view the entire series please visit http://www.insideria.com/series-facebook-dev.html

Read more from Mirza Hatipovic. Mirza Hatipovic's Atom feed mirzahat on Twitter

Comments

33 Comments

Coolania said:

Hi, where can I find the article 1,2 or 3?

Mirza said:

Hi,

it will be published next week. :-)

Every week a new one will be published.

Regards,
Mirza

Rachelj said:

The whole series will be aggregated at http://insideria.com/series-facebook-dev.html. If you'd like to get these in a feed, you can subscribe to Mirza's feed: http://www.insideria.com/mirza-hatipovic/atom.xml

David Dunkins said:

Dear Mirza,

I readed your tutorial because of the problem I have with Flash-PHP integration in Facebook application development. I think that following line of your code is wrong:

fb:swf swfsrc='http://www.yourServer.com/yourApp/main.swf' allowscriptaccess='always' bgcolor='#ffffff' wmode='transparent' flashvars='' width='500' height='400'

because facebook owerride allowscriptaccess always with "NEVER" value. I have problem with transfering variables from Flash to PHP, because actionscript addition to SEND or GETURL commands: "_self" "_top" and "_parrent" dont work if allowscriptaccess is set to NEVER. Only "_blank" work, but this command always open NEW WINDOW, which is not acceptable by my program.

Do You have some solution to this problem ?

How can you transfer variable from FLASH to PHP witouth opening a new window ?

Thanks for yor answer in advance.

Mirza said:

Hi David,

I know about this issue...indeed the allowscriptaccess value is always set to never. In the later tutorials (article 3 and 5) there are methods explained how to transfer all kinds of php variables from to flash on the fb platform...so please be patient :-)

Sanel said:

Svaka cast buraz, samo naprijed!!!
Pozdrav

Hi Mirza,

I'm follow this tutorial, but i have problems with Php conection to facebook. When i test the app, facebook send a error like this:
Parse error: syntax error, unexpected T_STRING, expecting '(' in /homepages/23/d245/htdocs/probes/main.php on line 20

I have installed the client library and i am testing with php 5 and php4client.
and i don't get the return values from facebook.
Can you help me, plese
Thank you.

Hi,

About my last comment:

The message error from facebook when i use the php 5 client library is this:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/23/d245/htdocs/probes/php/facebook.php on line 38

Thank you

Hey thanks for the tutorial, its great!

Anyway i follow some minor rev (code/tag) on Facebook, example $fb_user is changed to $user. And some other minor rev.

But thats okay, i love your tutorial!! Keep it update, im your fan! =D


Naeem said:

Please send me a code

Thanks for sharing

Mirza said:

You welcome :-)

Gompa said:

I have some problem when testing. I put everything but when I test, instead of getting in the first part the blank page i get these part of the php document displayed: "require_login(); //check if the user has added the app if (!$facebook->api_client->users_isAppUser()) { //if not, redirect him to add it $facebook->redirect($facebook->get_add_url()); }". What could it be?

Mirza said:

Gompa,

it seems like you facebook pages are not saved as php :-) they are parsed as normal html documents...check your file extensions, also check if your server supports php

Your application fails in PHP5. I get an error message saying that says

Cannot use string offset as an array in /home/content/w/o/r/worldshaker/html/facebook/fbflash/index.php on line 62.

Which is a PHP5 error from what I have found. I have been looking at your code but I am not a PHP expert. If you have a fix for this please post it for people using PHP5 and up.

Thanks,

Your application fails in PHP5. I get an error message saying that says

Cannot use string offset as an array in /home/content/w/o/r/worldshaker/html/facebook/fbflash/index.php on line 62.

Which is a PHP5 error from what I have found. I have been looking at your code but I am not a PHP expert. If you have a fix for this please post it for people using PHP5 and up.

The error is in here.

$img = $profileImages[$i]['pic_big'];
$status = urlencode($statuses[$i]['status']['message']);
//concat the strings
$queryStr .= ("image".($i + 1)."=".$img."&status".($i + 1)."=".$status."&");

line 62 is the $img = $profileImages[$i]['pic_big']; line

and

$status = urlencode($statuses[$i]['status']['message']);

will produce the error also.

Thanks,

Your application fails in PHP5. I get an error message saying that says

Cannot use string offset as an array in /home/content/w/o/r/worldshaker/html/facebook/fbflash/index.php on line 62.

Which is a PHP5 error from what I have found. I have been looking at your code but I am not a PHP expert. If you have a fix for this please post it for people using PHP5 and up.

The error is in here.

$img = $profileImages[$i]['pic_big'];
$status = urlencode($statuses[$i]['status']['message']);
//concat the strings
$queryStr .= ("image".($i + 1)."=".$img."&status".($i + 1)."=".$status."&");

line 62 is the $img = $profileImages[$i]['pic_big']; line

and

$status = urlencode($statuses[$i]['status']['message']);

will produce the error also.

Thanks,

Binoy said:

Hi,

Nice article..

I have one doubt. From my site, I am accepting facebook login. Once the user login to the site, I need to display my friends email address in one select box. How can I do it ?

Regards
Binoy

Thanks , New to the blog & api – great resource!

I’ve gotten through day one of getting things to work as a Flex desktop-mode app in debug, but I’m having trouble getting it to actually launch from Facebook.

Anastasia said:

Thank you for the great tutorial! Looking forward to diving into the rest of the series.

I'm not sure if you cover this in next tutorials, but in this case a better approach would be to use FQL. This way you will only make one API call instead of several, simplify things on the PHP side, also take care of filtering out users with no status message.

CODE:
---------------------------------------------------------------------

// Select 10 random friends whose status is not empty.
$fql = 'SELECT pic_big, status.message FROM user
WHERE status.message != ""
AND uid IN (SELECT uid2 FROM friend WHERE uid1 = ' . $user->id . ')
ORDER BY rand() LIMIT 10';
$result = $facebook->api_client->fql_query($fql);

// Create the query string.
$query = '?';
foreach ($result as $i => $friend_data) {
$query .= 'image' . ($i + 1) . '=' . $friend_data['pic_big'] . '&status' . ($i + 1) . '=' . urlencode($friend_data['status']['message']) . '&';
}

Badger Manufacture said:

Thanks for this tutorial. I have managed to load my 'main.swf' from the first tutorial but cant access the thumbnail from my UIloader (I have named it img_mc in the property inspector).

I note that the UIcopnenet is no longer referred to as 'fl.containers.UIloader' but now simply 'UIloader' in Flash CS4. Would this impact the tutorial at all, or perhaps be the reason that I'm not loading the tumbnail successfully?

Thanks again, I raelly hope that you can help.

:)

Badger Manufacture said:

Sorry to spam the page!! And thanks agan for all your help to such a beginner.

When you incluide the facebook api in main.php, is this supposed to be modified with a url to the facebook.php file?

"pathToYourFacebookLibrary/facebook/client/facebook.php"

Or does this stay the same?

I'm honestly not sure why the flash file is loading, but can't access the thumbnail!! lol

Thanks again
Badger

master nic said:

thanx....but i have problem...i want that facebook script which send direct message to facebook account..please help me..waiting for reply today.

Badger said:

Great work on the Hair Cut Stylist App!! Awesome, and looking forward to the complete series that you have started on Youtube.

I have had 2 apps approved since I last posted, so I'm now up to speed on the Facebook API, to a reasonable level (been coding for years too).

I'm still having difficulty passing flashvars to CS4. I assume that you dont need the Facebook libraries or rather the SWC for this tutorial to work? The swf still loads, but with no image.

Hope you can help at all, and that all is going well,

Best
Barnaby

Badger said:

I just got this to work after a month of practising/working hard on Facebook app development. Thanks so much for all your help my friend. I will forward the results after I have a chance to move onto your next tutorials!! Without this, I wouldn't have been able to link Flash to Facebook, I thank you again.

:D

Best
Badger

Badger said:

I added code to ensure that it doesn't display the same image twice consecutively:

function switchUser(e:TimerEvent)
{
var oldrandNum:Number = randNum;
var randNum:Number = Math.round(Math.random() * 6) + 1;

// while oldrandNum is equal to randNum, pick another until unique
while(oldrandNum = randNum)
{
var randNum:Number = Math.round(Math.random() * 6) + 1;
}

Works fine, I also have set the alpha to 70% and put an image behind. Looks very 'Flash'!!

@Anastasia:

I like the idea of using fql, but there are syntax errors in your code. The following should work better for fql:

$friends = $facebook->api_client->friends_get();

// Select 10 random friends whose status is not empty.
$fql = 'SELECT first_name,last_name,pic_square, status.message FROM user WHERE status.message != ""
AND uid IN (SELECT uid2 FROM friend WHERE uid1 = ' . $fb_user . ') ORDER BY rand() LIMIT 20';
$result = $facebook->api_client->fql_query($fql);
echo"
result: " . $result . "

";

// Create the query string.
$query = '?';
for($i=0; $i {
$query .=
("image".($i + 1)."=".
$result[$i]['pic_square'].
"&status".($i + 1)."=".
urlencode($result[$i]['status']['message']).
"&name".($i + 1)."=".
urlencode($result[$i]['first_name']." ".$result[$i]['last_name'])."&");
}

echo"
QUERY STRING: " . $query . "

";

srb said:

Hi,
I am unable to pass the variable containing the url to the image to the flash app.

My flash app works fine when invoked directly with the image url as argument:
example: http://my.hostserver.com/flashdemo/lesson2.swf?photo=http://www.flash-mx.com/images/image2.jpg

My flash also loads fine in facebook. But the image is not loading. The PHP snippet is below:

fb:swf swfsrc='http://my.hostserver.com/flashdemosrb/lesson2.swf?photo=http://www.flash-mx.com/images/image1.jpg' allowscriptaccess='always' bgcolor='#ffffff' wmode='transparent' flashvars='' width='500' height='400'/

I also tried the below code without success:

fb:swf swfsrc='http://my.hostserver.com/flashdemosrb/lesson2.swf?photo=' allowscriptaccess='always' bgcolor='#ffffff' wmode='transparent' flashvars='' width='500' height='400'/

my $photo variable has the correct value for image url.

Any ideas on what may be going wrong here?

Thanks, srb.

Moe said:

I didn't find: facebook/client/facebook.php

and i got the API class from:
http://code.google.com/p/facebook-actionscript-api/

Do i have the right classes?

Esmin said:

Thanks for this great tutorial.

UILoader does load image indeed, but loading image via urlRequest and Loader does not. Is there a known issue about this?

tom said:

WOW! Great post man I will see what i can come up with

Thanks
http://www.facebookloginhut.com/

Anonymous said:

Hi,
followed the tutorial up to the bit when I am displaying the first image but I got this message: The URL http://www.............returned HTTP code 200 and no data. Does anyone know why?

kevin said:

Anonymous...try putting the API key & secret key in single quotes. That seemed to work for my but now my page is just blank. It's not loading the .swf file.

Leave a comment


Tag Cloud

Question of the Week: Dream App

If you had an unlimited budget and unlimited resources what application would you build and why would you build it?

Answer

Latest Features

Recommended for You

@InsideRIA on Twitter

Archives

  • Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.