in Conferences

New video tutorial on using AMFPHP

As promised, here is the first in a series of tutorials on using AMFPHP. In the tutorial I show you how to download and install AMFPHP on your web server. From there we build a simple PHP service class that sends email. Finally we go into Flash and write the ActionScript code needed to call the the AMFPHP service. Go and check it out at http://www.gotoandlearn.com and let me know what you think.

Lee

Write a Comment

Comment

61 Comments

  1. Is there some setting in WAMP that would cause an error each time I click “call”? I can’t seem to get it to work. I’ll keep looking at it.

    The error says: “(Object)#0
    message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’mail(): “sendmail_from” not set in php.ini or custom “From:” header missing’ faultDetail:’C:\wamp\www\amfphp\services\Email.php on line 11′”
    name = “Error”
    rootCause = (null)”

    I looked through the PHP.ini file and changed the defaults inside it, but to no avail.

  2. @DJ This looks like a general PHP error. Try making a regular PHP script that calls the mail() function and see if it works.

  3. Oh and it could be to do with the fact that you are running it locally. Try uploading to your web server to see if it works. That is why I always just do things on a live server :-)

  4. Oh, forgot to mention, this happens when I click “call” from the DiscoveryService as well. Same error. And I don’t know if this is our differing servers or what, but in your video the “$”‘s appear before your variable names, but mine do not. This is a little embarrassing to mess up something so simple. Lol.

  5. @oliver_l1 Yes you will need to use the email example on a live server unless you have sendmail working on your system.

  6. Hey Lee, I noticed you’re using Transmit, which I also use. But I’ve been wading into Forklift, especially for it’s batch-rename feature, but also for the dual paned dual FTP window layout. Like Transmit you have two windows, but both can be separate FTP connections. Small, but neat for transferring stuff around server/s. The only downside is it’s just recently come out of beta, and is still somewhat buggy, and lacking in performance.

    http://binarynights.com/

  7. Hi, nice video. I guess my last post got lost. You compare it only to xml, can you also compare it to an httpService using ie. the sepy serializer class? I made a lot good experiences with this, because I am able to use a phpframework, but I am not sure if lose a lot of the AMF features. Now it is a little bit confusing which technic to use best.?

    Thank you very mich,
    Chris

  8. I made an example of using the magpie php framework with AMFPHP
    http://gfxcomplex.com/blog/amfphp/overcome-flash-and-rss-crossdomain-problems-with-amfphp-and-magpie/

    Heres just a few things why I did that.
    1# pars out RSS into native AS3 object on the server side
    2# a great workaround for the crossdomain.xml file for servers with out one
    3# Parses RSS 0.9 – RSS 1.0.
    4# Integrated Object Cache

    Basically it brings all the great things about this PHP framework and brings it to AS3.

    Another great place for amfphp examples is Bytearray.org where he does a lot of really great things with AMFPHP. He was one of the first guys I seen that sent a byteArray of a JPG to AMFPHP with his video snapshot example.

    One a side note about your comment about gateways.
    I always thought of the gateway being like a link from one language to the next. So in a way I always thought of AMFPHP as the gateway it’s self.

  9. you are the best lee
    but i need to know something does this support Asian and middle East languages like Japanese and chines ????????

  10. Hi

    it does work locally but you have to have curly braces for the class.

    lee, i cannot say how much i learn from you.your video tutorials and the blog itself is a daily place for me.

    thanks

    ron

  11. just a question:

    i got a php5 ready server at my hand, yet when i upload the amfphp folder and locate my browser to mydomain.com(obviously my realdomain)/amfphp/browser/

    i get this remarkable error:
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, support@one.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    _________
    nonetheless thanks for this tutorial

  12. Hello ..nice tut but i cant find a clear way to secure my amfphp cms with a login/ logout method..maybe u can show how to do it in the next tutorial?
    A.

  13. Nice one Lee,

    I’ve been playing with this for a while at work on our PHP/Flash projects and you really can do some great things with it. One thing I’d like to add – if you want to make amfphp more global within a website you can pull gateway.php out into the main directory and change the two include paths to point into the amfphp folder. You will then also need to edit the globals.php file and update the $servicesPath and $voPath to reflect the new changes.

    It’s also possible to modify these paths to tap into existing PHP classes that you might have created or to use classes from the Zend framework or CodeIgniter (which I highly recommend). This can be a really powerful tool for getting dynamic data in and out of Flash.

  14. Hi Lee,
    allways great tutorial- I’m using AMFPHP extensivly with Flex and i tried your example with FlashDevelop (without Flash IDE) – but i didn’t get any output – no onResult, no onFault – do you have any ideas why it wont work, when running it as Document-Class

  15. If you are you using 1and1 hosting or any hosting that runs multiple versions of PHP concurrently you must REPLACE the text in the .htaccess file with…

    AddType x-mapp-php5 .php
    AddHandler x-mapp-php5 .php

    this will make sure that all php files are read as PHP5.

  16. The .htaccess file was also playing up on my 1and1 (linux) account. It was returning Internal 500 errors on any file you tried to access within the amfphp folder (even txt files).

    Remaming the .htaccess file that lives in the /amfphp folder did the trick though and now it’s working just fine ;)

  17. @boris:

    hey …thank you for the hint! I had the exact same problem with my shared hosting account. i thought you’d have to have root access to place the amfphp folder in the correct position, but now …it works :-))

    thanks again
    Stefan

  18. Great tutorial yet again. Thanks Lee.

    AMFPHP can be used to leverage the open-source Drupal CMS and enable Flash websites/applications to use Drupal as a CMS for Flash (or Flex obviously). It is an incredibly powerful solution and is already being used by companies. A fairly decent example can be seen here: http://flex.org/showcase/

    You can see more about Drupal here: http://drupal.org/
    and get the modules that enable Flash to communicate with Drupal via AMFPHP here: http://drupal.org/project/services
    and here: http://drupal.org/project/amfphp

    I would love to see the AMFPHP tutorials expanded into showing integration with Drupal.

  19. FYI, the Flex.org showcase has a write up on Adobe about how they achieved the showcase with Drupal and Flex. The Adobe article is here: http://www.adobe.com/devnet/flex/articles/drupal.html

    There are loads of examples of how to use Flex to integrate with Drupal, but none that I can find on using Flash CS3 and AS3. I just thought it might be useful for people to know as there aren’t too many CMS’s out there (let alone open source ones) that can allow an easy(ish) integration with Flash.

  20. Lee:

    Firstly, top-notch video. I have no idea why there is such a dearth of good solid information on AMFPHP, but your video is very clear and easy to understand.

    Some requests: nobody seems to be doing the same thing for Flex as you’re doing for Flash. While this video is excellent, in my opinion it would have been even better if you had added five or 10 minutes and simply tacked on doing the same thing in Flex as you had in Flash all in this aim video. The PHP parts are all identical whether you’re accessing it by Flash or Flex. The Flex version is significantly different (RemoteObject usage, the services-config.xml file and so on), and while Flex and AMFPHP are often written about on the Internet, it’s never done very well. I’m still not clear, for example, as to whether you actually HAVE to use the services-config.xml file with Flex or whether you can get away with just using endpoint.

    There are a few tutorials on using Flex and AMFPHP, but they all read like cookbooks with little or no in-depth explanation of what the options are or what the background meaning is of each step.

    Anyhow, just a suggestion.

  21. Can i include the remote class of Flahs CS3 into Flsh 8 projects?

    I am asking this, because i am making a site for a custome and also i haven’t learned yet the Action Script 3 in order to built the site in Flash CS3

  22. Hi
    i played with amfphp and its great. but when i try to pass or extract Hebrew records from a database, it returns as symbols. the database is set to utf-8.

    so i tried just to check a variable (no database) that holds an Hebrew name, and got the symbols.

    is there a way to work with amfphp with non Latin languages?

    best regards

    ron

  23. Hi

    if someone found himself stuck with my problem above. i found the answer: change the setCharHandler in the gateway.php file to utf-8.

    home this is helpful

    ron

  24. When I clicked on the “here” to view the video, I get the followings:

    Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (error)’ in /nfs/c01/h02/mnt/33756/domains/gotoandlearn.com/library/Zend/Controller/Dispatcher/Standard.php:249 Stack trace: #0 /nfs/c01/h02/mnt/33756/domains/gotoandlearn.com/library/Zend/Controller/Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /nfs/c01/h02/mnt/33756/domains/gotoandlearn.com/library/Zend/Controller/Front.php(226): Zend_Controller_Front->dispatch() #2 /nfs/c01/h02/mnt/33756/domains/gotoandlearn.com/html/index.php(19): Zend_Controller_Front::run(‘../application/…’) #3 {main} thrown in /nfs/c01/h02/mnt/33756/domains/gotoandlearn.com/library/Zend/Controller/Dispatcher/Standard.php on line 249

    Any idea? I want to know how to get amfphp to work on localhost AND on the server. I installed WAMP and downloaded the entire amfphp folder into c:/wamp/www directory. When I goto http://localhost/amfphp/browser/ I was able to see the AMF directory, however, when I do a call “describeService” I got the following error:

    (Object)#0
    message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’The MethodTable class could not find {C:\wamp\www\amfphp\services/C:\wamp\www\amfphp\services\.php}’ faultDetail:’C:\wamp\www\amfphp\core\shared\util\MethodTable.php on line 92′”
    name = “Error”
    rootCause = (null)

    Call on method: getServices I got:

    (Array)#0
    [0] (Object)#1
    children = (Array)#2
    [0] (Object)#3
    data = “amfphp\”
    label = “DiscoveryService”
    label = “amfphp”
    open = true

    And call on method: getTemplates I got:

    (Object)#0
    message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’opendir(templates): failed to open dir: No error’ faultDetail:’C:\wamp\www\amfphp\services\amfphp\DiscoveryService.php on line 121′”
    name = “Error”
    rootCause = (null)

    Now, when I put the entire folder on my server, I got an Internal Server Error:

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    What am I doing wrong? Please help.

  25. I’m getting this error. Any ideas ?
    (Object)#0
    message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’The MethodTable class could not find {/var/www/vhosts/dumpyemail.com/httpdocs/amfphp/services//var/www/vhosts/dumpyemail/com/httpdocs/amfphp/services/.php}’ faultDetail:’/var/www/vhosts/dumpyemail.com/httpdocs/amfphp/core/shared/util/MethodTable.php on line 92′”
    name = “Error”
    rootCause = (null)

  26. I have the same issue as DJ above.

    (Object)#0
    message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’mail(): “sendmail_from” not set in php.ini or custom “From:” header missing’

    The following email script works on my server:

    $from,
    ‘To’ => $to,
    ‘Subject’ => $subject);
    $smtp = Mail::factory(‘smtp’, $params);

    $mail = $smtp->send($to, $headers, $body);

    }
    ?>

    Does anyone know how I would modify the email class to send these parameters? I don’t know much about classes.

    Thanks
    Scott

  27. Sorry, the code got clipped. Here is the code that works.

    $from,
    ‘To’ => $to,
    ‘Subject’ => $subject);
    $smtp = Mail::factory(‘smtp’, $params);

    $mail = $smtp->send($to, $headers, $body);

    }
    ?>

  28. after searching the web for few days i found this :
    to view utf-8 languages like Hebrew and so on
    you need to run:
    SET NAMES ‘utf8′ command
    like this in php class:
    mysql_query(“SET NAMES ‘utf8′”);
    works for me
    just want to share & save u all some time

  29. All,

    I followed the steps to setting up amfphp on my site.

    I then tried to view the service browser:

    http://mydomain.com/amfphp/browser/

    The browser loads without a problem.

    I then FTP’d the Email.php file to the correct location. It shows up in the left column of service browser.

    But when I click it to inspect it, and test it out, I get this error:

    “Error retrieving service info:

    Invalid AMF message”

    Any idea what the issue is? What have I done wrong?

    Many thanks in advance.

  30. Hey Lee, thanks for the info, but for some reason, I am getting an error
    The class {Service} could not be found under the class path {C:\wampserver\www\amfphp\services/Service.php}
    33
    AMFPHP_FILE_NOT_FOUND
    C:\wampserver\www\amfphp\core\shared\app\BasicActions.php
    User Error

    now, the weird thing is that it actually shows up in my localhost/browser window… pulling everything in, but it seems like it is referencing some Services file that I have no idea about.

    Thanks

  31. im trying to run the email.php code on my webserver but it’s not working. it’s giving me the following error:

    (Object)#0
    message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’mail(): “sendmail_from” not set in php.ini or custom “From:” header missing’ faultDetail:’E:\web\justintimo1\htdocs\amfphp\services\Email.php on line 13′”
    name = “Error”
    rootCause = (null)
    how could i set the “sendmail_from” in php
    however i have done everything as shown in the tutorial

    Thanks in advance

    Garo

  32. hi,Lee
    sorry to disturb you, but the AMFphp 1.9 is not compatible with new version of php 5.29 because of the deprecation of the function eregi_replace()(it has been discarded in the new php version).

    any ideal to sovle the problem?

    Thank you!
    Your fun:)

  33. Hello!
    sorry to disturb you but will you be able to tell that wather it will be working or not on a local host
    Thank you!

  34. (Object)#0
    message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’mail(): Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set()’ faultDetail:’C:\wamp\www\amfphp 1.9\services\Email.php on line 11′”
    name = “Error”
    rootCause = (null)

    please solve this problem
    thank U
    parames

  35. it’s great to learn about this amf! thanx you very much
    the videos are cool and very instructive

    all the scripts works fine with amfphp/browser, but sadly i receive a Flash error when i execute script (both tutorials) that says:
    1120: Accès à la propriété non définie Email. (access to the propery Email not defined)
    at line: gw.call(Email.send, res, …);
    and the same in the second video

    i’m working localy with wamp2 for testing purpose (php 5.2.9, apache 2.2.11) and flash cs4.
    The url i use is: gw.connect(“http://localhost/AMF/amfphp-1.9/gateway.php”);

    i read i could be a crossdomain problem but i don’t know how to solve it! anyone have clue ?

    For those with sendmail_from error, you have to set smtp settings for your scripts, manually: edit php.ini settings, or within the script:

  36. For some reason, the script is not working properly when .swf being launched from server:

    cleostem.co.uk/amfphp.swf

    Presume it’s a pretty simple one but can’t figure it out (guess the ‘call’ method might be missing smth);

    It’d be lovely to have some help if anyone knows! (Thanks!)