Flash, amfphp, xmlrpc module interfacing. need help.

averageyoungman - September 26, 2005 - 13:32

Hello,

I am building a site for a photgrapher which will have a Flash front end. I have installed amfphp, and it is working fine. I would like to use the xmlrpc.module to retrieve the node information I need, but I am stuck in a couple of instances.

Flash / amfphp, it appears, cannot interface with a module directly, therefore I need a "service" PHP file which interfaces with Drupal's xmlrpc library and module. So, here's where I am getting confused:

How do I create the interface between this "service" file, the xmlrpc library and the xmlrpc.module? Is it simply an include, and then usage of xmlrpc methods? Also, if I write a custom module that returns the information I need via hook_xmlrpc, what is the method of calling a particular function? I understand how it is used with functions described locally, but the interaction with Drupal is really confusing me.

I searched the forums and found this post, which is essentially what I would like to do, but it makes no mention of the interface method to use between Drupal / xmlrpc and the "service.php" file.

Basically, I need to get an XML formatted list of images in hierarchical taxonomy form back from Drupal.
I have looked at the blogapi.module as well as the documentation regarding converting modules to the new xmlrpc library. Those have helped, but I am still getting confused where I referenced above.

I know that there is interest in expanded usage of the xmlrpc.module in this context, so any help is greatly appreciated as always.

Thank you,

-- aym

Bump

averageyoungman - September 27, 2005 - 13:55

Hate me for the bump, but take pity on me for my problem, and help??

Please??

-- aym

Sessions

eldarin - September 27, 2005 - 14:27

One thing I gather is an issue is carrying the session - authenticated by the sessionid - over to the Flash environment. One possibilty - possible the simplest - is using the flashvars which initializes the Flash application. That way you would be including the session-id in XHTML (via the theme'd pages etc.).

I have used amfphp a little, but not directly with Drupal yet. I went with OpenLaszlo for that. I will revisit amfphp+Drupal, but I think it's a fairly new area for most, and perhaps not so many with any experience combining the two - ergo the lack of responses.

The 1.0 release of amfphp earlier was very anticipated in the amfphp-community, I remember, so some will probably come up with some working blueprints for integration.

My solution for getting the XML is "unorthodox" and involves the theme engine I made, partly to address my needs for XML. However, the newer XMLRPC file might be better suited and avoid all the security problems which hampered use of the former version.

There is no good solution to finer granularity on security for the XMLRPC at the moment, I think. Earlier this year, when I was looking through Drupal issues (on the project pages) on XMLRPC, it seemed like something very few were using or had any strong opinions on.

You are mostly on your own until you find someone willing to share more - and having the experience to boot. ;-)

My lonely problem...

averageyoungman - September 27, 2005 - 14:42

Just got a little less lonely. ;-) Thanks for the reply.

How did you integrate OPenLaszlo with Drupal?

In my case, I don't think I have to worry about anything regarding the session, as this site will not incorporate any specific user based functionality. It's just presentation. All i really need is a method of interfacing AMFPHP with Drupal's API via XMLRPC. Haha! Sounds nuts.

I actually worked for Laszlo as a freelancer. I helped translate their original animation engine from Director to Flash, and worked with many of their employees while I was at the @Home Network. Of course for some reason I didn't even think about using OpenLaszlo. Thanks for the heads-up. I will check it out.

-- aym

Laszlo

eldarin - September 27, 2005 - 15:20

I use Eclipse and the IBM plugin for environment - the Tomcat lps-server/lzx-factory is great for developing.
I make them standalone - not compiled and proxied="false" and use the 3.0 version (which still has some memory leaks with regards to remoting).

Laszlo is "a bit" more snazzy than amfphp ... ;-D

I just made a module which makes heavy use of theme() calls to produce the XML. I deliver the final output via theme-templates. I am not sure how this would work with something like PHPTemplate, but maybe it is possible. I prefered the XTemplate syntax for best match to my needs.

Remember the header's being produced too if you want to be totally correct (see common.inc).

Getting it into Laszlo datasets is easy once you have the XML. ;-)

Originally, I looked at a lot of stuff like Zulu, flashjs and similar solutions, but OpenLaszlo seemed the best developed one. It gets a little bloated - but not a lot if designing carefully; and v3.1 is right aroundt the corner.

Thanks!

averageyoungman - September 27, 2005 - 15:22

I will look into this and report back with any findings. I am on deadline but I would really rather not create a method of data extraction too independent of the Drupal API.

I'm on Unix using 4.6.3 and phptemplate, but I'll see if I can work this out. I know tons of people at Laszlo, so hopefully they will be able to help me along.

One question, if you're inclined to answer: do you access your module directly via remoting, or is there a file in between that handles access to the module? I hope that's not a stupid question.

Thanks again for the - hopefully - rude awakening, and thanks a ton for your time!

-- aym

Extraction

eldarin - September 27, 2005 - 15:35

I get the XML in a fairly Drupal'ish way, by using the dynamic module-menu-system and just dressing up the content appropriately. I thought about stuff like XSLT, but currently only use the theme-engine I made for this and other purposes. The theme() calls don't make so much sense for now in my approach - since the output is so specialized. It could be possible to go the XSLT route though, but it works fine like it is for now.

So, the module makes paths available using Drupal core, and other modules for authorization. These paths are sources for the Laszlo datasets. I have an "external" authorization mechanism using the URL requested, but you could share the session if needed - although not applicable in your case (yet?). The module creating the XML serves it finally with the theme('page') function like normal.

I.e it's pretty much "normal Drupal" and not anything fancy, but "some" modifications are needed - especially on theme-engine to get the XML output.

I think you have a way better foundation than me to get it working after the sound of things. ;-)

A tip is that the solution of using the theme-engine can give potentially very easy access to all Drupal-content via XML. *hint*

Thanks again...

averageyoungman - September 27, 2005 - 15:45

For all the info! I am a little lost on the Laszlo/module interaction (not the datasets portion,) but I gather that is because I haven't messed with laszlo for so long. I will definitely report back if I find success. Thanks so much for the guidance.

-- aym

Modules

eldarin - September 27, 2005 - 17:03

Take something simplistic like the story.module and figure how it works. Then make a simple module, and use the theme() functions. Finally, look at how the theme-engines work and how XHTML is produced by the _page theme-hook (see theme() in theme.inc ).

That was my approach, and not using XMLRPC. A new and improved XMLRPC version will probably surface with Drupal 4.7 a little later, since it involved changes elsewhere in Drupal core.

Remember, the Laszlo datasets only request a URL like any other normal http-request. You can serve what you want on URLs, with the right callbacks defined in the _menu-hooks and control over the theme'd output (the theme-engines). You could even do POSTs.

Interestingly enough, I just

logictude - September 27, 2005 - 16:41

Interestingly enough, I just did this exact thing and tried it the exact same way. I ran into trouble when it came time to branch from amfphp to xmlrpc too. There was a lot of headache here, so I went a different route.

I grabbed the XMLRPC Flash component, here (http://xmlrpcflash.dopelogik.com/) and used that. Now I just make my XMLRPC call to Drupal's XMLRPC interface directly. This, of course, assumes you have a module that uses the XMLRPC to interface with the system. The blogapi.module, as mentioned above, works, if those are the functions you need.

It sounds as if you'll need to author a module to do what you need.

I still use AMFPHP for a lot of database communication, although I could migrate to XMLRPC 100%. It would probably be smart.

Let me know if you have any more questions.

I think i understand...

averageyoungman - September 27, 2005 - 17:40

your last description. I think it goes like this:

• Flash makes a request to Drupal's XMLRPC interface via the Flash/XMLRPC component, sending a reference to the function to be called via the method: rpc.call (function.functionname)

• The XMLRPC library calls the function in my custom module which uses hook_xmlrpc to describe the list of available, XMLRPC specific functions

• My function selects the appropriate data from the DB, and returns it to the XMLRPC library for formatting

• The XMLRPC library returns the formatted XML to Flash?

I think I may be missing a step or param here, but is this the general gist? I took a look at the XMLRPC for Flash site, and I think I have a grasp on how to use it. Honestly, where I get lost is in the granularities. For instance, the sample code on the Flash/XMLRPC componenet page makes the connection to what appears - to me - to be a directory called "rpc" and not a specific file. Also, the example in the component download connects directly to a server, and my lack of expertise here makes that a bit confusing. So I guess where I am confused here is: what is the Flash/XMLRPC component syntax for hooking into Drupal's XMLRCP library?

This seems to be a very good solution, and I can't thank you enough for helping. I really, really appreciate it. Please let me know if you ever need any help with anything, as I will be more than willing to assist.

- aym

You've Got the Gist

logictude - September 27, 2005 - 18:15

The flow is pretty accurate. Flash to XML Component to XMLRPC Interface to Hook_XMLRPC (Provided via a module) and back.

Your module will use the XMLRPC includes provided with Drupal to format the data to be returned to your Flash app.

Here's a sample that works for me.

The flow is pretty accurate. Flash to XML Component to XMLRPC Interface to Hook_XMLRPC (Provided via a module) and back.

Your module will use the XMLRPC includes provided with Drupal to format the data to be returned to your Flash app.

Here's a sample that works for me.

//make new RPC Connection Object
var RPCConn = new XMLRPC.Connection();
RPCConn.Server = "http://domain.com/xmlrpc.php";
RPCConn.Quiet = true;
//Handle method response
RPCConn.OnLoad = function(r) {
if (this.IsLoaded()) {
// work with your data
}
};
//Clear old parameters, usually shouldn't be any
RPCConn.ClearParameters();
//no parameters needed
RPCConn.AddParameter(username_tf.text, XMLRPC.types.STRING);
RPCConn.AddParameter(password_tf.text, XMLRPC.types.STRING);
//Call Method
RPCConn.Call("flashconduit.login");

To fill out the story, I wrote a small module called flashconduit that has an XMLRPC method called 'login'. As you can tell, this is a script for a Flash login window.

Holy crap it works!!

averageyoungman - September 27, 2005 - 22:31

Thank you!

It even makes the nightmare of working with the Flash debugging blindfold on tolerable! Haha!

This is pretty damn cool though. I am wondering about one thing however...

The second array present in each function description in blogapi.module is confusing me. They appear to be parameters, however the number of parameters does not match the accompanying function call in the file. Does this parameter list pass the desired data type for each result back to xmlrpc.php? I have scoured the forrums and handbook looking for a direct referrence, but can't find it. The newest entry in the handbook referring to the XMLRPC API has what seems to be some contradictory information. Any clue?

Man, thanks so much. I owe you a virtual beer. I had been reading your previous post regarding this combo of technologies over and over again to see if I was missing something. I will definitely report back with any findings I may stumble upon.

-- aym

No Worries

logictude - September 27, 2005 - 23:27

I think you're specifically asking about http://drupaldocs.org/api/head/function/hook_xmlrpc. There's an explanation about the array you're talking about. The fact that they don't line up is probably a legacy/standards issue.

I would ultimately like to see more Flash-to-XMLRPC-to-Drupal use. I have one application now that is using a lot of AMFPHP and it's pretty trustworthy. I'd like to migrate entirely to XMLRPC and remove the middle-ware.

We should work on a project together, bringing focus to the XMLRPC interface. I know it's being used for blogging purposes, but what about other uses. What about an alternative administrative interface written in Flash that interacts with the system via XMLRPC. Or, even cooler, strap the XPCharting components to a Flash application and provide graphic representations of the Drupal-captured statistics.

Anyway, good to hear you're up and running.

Also see ..

eldarin - September 28, 2005 - 00:23

.. this post : http://drupal.org/node/6120#comment-11144 .
And then the one about the new XMLRPC - http://drupal.org/node/28913 and perhaps even http://drupal.org/node/22218 .
There is also the one about the new xmlrpc file itself - initiated from http://drupal.org/node/25600#comment-34415 - and complete in - http://drupal.org/node/26391 .

I don't use the XMLRPC myself for various reasons, but am very interested in seeing how you guys fare. Also see the other poster in the first link I provided, which might have similar goals. I might revisit amfphp for something else, while continuing to use Openlaszlo for now, so maybe I'll be able to help out. Not so many of us fiddling with Flash here it seems.
;-)

Hope the collection of issues above give some input too - at least some headsup on the XMLRPC changes imminient.

Absolutely!

averageyoungman - September 28, 2005 - 15:02

I am totally willing to work on a project and help in any way I possibly can. In this case, I will be using it almost entirely for image node retrieval, as the site I am using it for is for a photographer. This will afford me the opportunity to evaluate it in this context. If you are intersted in an administrative interface, I'm more than willing to help.

I am also definitely interested in the potential of Laszlo and Drupal. With Laszlo's built in components - better than native Flash ones IMO - there is a ton of potential for module driven interfaces. I used to work with the majority of the Laszlo developers, so I'm sure we could get a lot of help from them. Specifically Bret Simister, who is a bonafied genius. I already got a response back from them regarding my interest in integrating with Drupal, and I pointed them to this thread, specifically eldarin's comments. I will stick with the XMLRPC for the moment however before I go too nuts. I still have to get a better comprehensive understanding of the XMLRPC API in general, as I am new to it.

I found the following explanation here:

This method [signature] takes one parameter, the name of a method implemented by the XML-RPC server.

It returns an array of possible signatures for this method. A signature is an array of types. The first of these types is the return type of the method, the rest are parameters.

So, based on that I assume that if the Drupal function returns three values, that array will have four entries, the first being the desired encapsulated return type - if any- for all the values and the rest being the types for each value. That makes sense to me. I hope I'm not confused. How that translates on the Flash end date-type-wise I still need to test thoroughly for myself, as I am a "touch the electric fence" kind of guy. Thanks again to both of you guys. I look forward to expanding on this stuff, and hopefully I can make a significant contribution.

-- aym

p.s. Andrew, after I posted this thread initially, I sent an email to Robert Douglass asking for help. He got back to me, and I sent him an email last night to make him aware of the progress in this thread. He asked that I write a handbook entry regarding the experience, and said that they would push it through moderation. I figure it should be you creating the handbook entry, as you have more experience with this technology combo. I figure that I can lend whatever experiences I have regarding images to the effort.

I Think So

logictude - September 28, 2005 - 16:32

I'll see what I can come up with for the Handbook entry.

averageyoungman
On a separate note, did you create a separate module for the xmlrpc hook or did you use the blogapi.module?

I created a separate module

averageyoungman - September 28, 2005 - 16:42

I just used the same name for testing - "flashconduit".

I'm still trying to figure out how to get the values I need back properly. I gather I am doing something wrong on the Flash end. I have essentially duplicated a blogapi function, but return different values, and I keep getting back "wrong number of method parameters" in the output window in Flash. That XMLRPC library spits out a lot of information which is good, I just have to get the interaction right.

-- aym

Can I get your...

averageyoungman - September 28, 2005 - 17:03

Email address?

Mine is in my contact form.

Let me know if you want anything from me on my end. I will try to post at the end of the day with further findings. What I'm seeing in general is that what I'm sending back gets stuffed into an object, e.g. methodResponse.mail, methodResponse.uid etc.

-- aym (justin)

ActionScript 2.0 / Ecmascript

eldarin - September 28, 2005 - 17:02

Remember that Laszlo also allows AS snippets in the < method > tags ...
... if you need a lot of stuff not "native" to OpenLaszlo.

I found that Laszlo made me accomplish what I wanted much faster than writing it all on my own, but then I guess I almost did "write it all on my own" by using the XML'ed theme-output and not the XMLRPC .. (although I'm unsure if XMLRPC could do all I wanted - especially with regards to general [and not XMLRPC-specific] security).
;-)

That's awesome

averageyoungman - September 28, 2005 - 17:05

I can't wait to really dig into it.

-- aym

update?

jyamada1 - October 23, 2005 - 21:01

just wondering how things are going on this project.

i am very interested in drupal integration with flash, especially as it applies to images and image galleries. hoping to one day be able to pass drupal data through a flash image gallery or slideshow on my frontpage.

anyway, any news?

Outdated thread, but still

matt2000 - June 11, 2008 - 06:32

Outdated thread, but still comes up in searches.

I hope everyone knows about Services module by now.

----
Drupal Micro-Blogging at Twitter

 
 

Drupal is a registered trademark of Dries Buytaert.