DrupalSite and Creating new nodes/updating nodes

Events happening in the community are now at Drupal community events on www.drupal.org.
cmcintosh's picture

I have tried everything i can think of to create a new node using the DrupalSite class from thirdavedesign and nothing works. I can get views, nodes, and other information just fine. However, when i try to login or save a node (new or update) it gives me a fail message(and not any details as to why/how it failed).

Anyone that has done this it would be great to get an example how to just create a simple page type node, i could figure out the rest from there i think. Also, any settings I need to have on drupal and in the flash file would be great insight also. currently i have my site NOT using keys or session ids, tried with them on and got same result. Thanks,
chris

Comments

check this

jacopo3001's picture

simple straightforward way yo create a node.
http://drupal.org/node/178085

I am sure DrupalSite is great class, but for simple operations may be too complex and hard to debug (at least for me)
I tried it and failed, now back to handwriting.
If you have any doubts post back.

You might be right with

cmcintosh's picture

You might be right with that. It has a lot of useful features and I used to to build this: http://chrismcintoshdesigns.com/flash but it is hard to debug and there is very little documentation or tutorials out on it.

Maybe we should get a hold of thirdave and see about maybe getting them to open up a contribute page on drupal. I think that if it was cleaned up and had some features added to it, it could be a really beneficial flash class.

I looked at that example, it

cmcintosh's picture

I looked at that example, it was for flex. I am having the hardest time finding anything for flash that i could look at and say ahh Ha! any tutorials you know about that are for flash AS 3.0, would be great(there are differences in flex/flash).

Look here:

Bensbury's picture

Hi Chris,

Did you figure it out?

I know what you mean. Figuring out services w/Flash for Drupal is a pain in the butt and the documentation is a bit dodgy.

Look here:

http://drupal.org/node/219365#comment-1569870

Entries #36 and #48 should cover it.
That's for AS3 I think.

You can mail me if you need any help with it.

Yea, I finally did figure

cmcintosh's picture

Yea, I finally did figure out what was needing to be done for drupalSite to create new nodes. Maybe this will help someone else out. There are several 'Mini' Steps that you should take in order to get everything lined up to work properly. I used a couple of timers to accomplish this and prevent the script from advancing before the connection or settings were made.

AS 3.0 Flash Main.as Class:

package {

// First grab all of the needed External Libraries
import flash.display.MovieClip; // Needed to extend movieclip class and attach to main timeline
import flash.events.TimerEvent;
import flash.utils.*;
import flash.display.LoaderInfo;

// DrupalSite Class
import com.thirdavedesign.drupalSite.*;

// Found a really nifty debugging class
import as3.utils.deepTrace; // Not Required but helpful in figuring out the structure of various objects passed in by drupal/services

public class Main extends MovieClip {

/*

Login information to allow the script to create nodes, I recommend creating an account just for this purpose

*/
private var _userName:String; // Username to login with
private var _password:String; // Password to use for login

private var _drupal:DrupalSite;  // Intantiate the DrupalSite Class
private var _drupalHost:String = 'YOURHOSTURL.COM/services/amfphp/gateway.php'; // It is a must to have clean urls turned on
private var _drupalKey:String = " "; // API Key used to authenticate the application
private var _timer:Timer;

public var DrupalConnected:Boolean = false; // Are we connected to our Drupal Site's services server?

/*

Class Construction function

*/

public function Main(host:String ='', apiKey:String = '', user:String = '', pass:String= ''):void
{

_drupalHost = host;
_drupalKey = apiKey;
_user = user;
_pass = pass;

if(host !== '' && apiKey !== '')
    {
            initDrupalConnection(host, apiKey); // We are now initiating the drupal connection
     }
}

// It is handy to have a public connection function in cases that we get disconnected from drupal for some reason
public function initDrupalConnection(host:String, apiKey:String):void
{

          _drupalHost = host;
          _drupalKey = apiKey;
          _drupal = new DrupalSite(_drupalHost, _drupalKey);

          // Start a timer to check the connection
          _timer = new Timer(400);
          _timer.addEventListener(TimerEvent.TIMER, checkConnection);
          _timer.start();
}

private function checkConnection(event:TimerEvent):void
{
          DrupalConnected = _drupal.CONNECTED;
          if(DrupalConnected)
          {
                  _timer.stop();
                 _drupal.login(_user, _pass); // This will start Logging us in
                                _timer = new Timer(400);
_timer.addEventListener(TimerEvent.TIMER, loggedIn);
_timer.start();
           }
}

/*

Check our log in status for node creation

*/
private function loggedIn(event:TimerEvent):void
{

    if(_drupal.UID !== 0)
    {
        _timer.stop();
        // We are now Logged in and can create nodes!

    } else {
       // You could put some sort of logging message here

    }
}


}

That is pretty much it. I will need to go through and explain it further later on, but I think that this should help a lot of us flash programmers gone drupal. Let me know if you have any questions or trouble implementing it.

}

rolf vreijdenberger's picture

Hi,

I posted this on some other posts here in the services group, but since you guys were explicitly asking for another way to interface with drupal, I wanted to point out that we've just released an opensource drupal interfacing as3 implementation.

It's part of a larger as3 toolkit/library of our company.

This one handles authentication keys and sessions and features all core services stuff for the 6.x version

check out an extensive blogpost including demo at http://www.dpdk.nl/opensource/drupalservice-as-a-bridge-between-flash-an...

Kind regards,

Rolf Vreijdenberger

drupal and flash: http://www.dpdk.nl/opensource/drupalproxy-as-a-bridge-between-flash-as3-...

karthi.srinivasan's picture

Hi,

I am using Drupal 6.x and services 6.2 with REST server.
I am able to create/ delete a node, by REST remote call.

But I could not edit or update a node using REST client with PUT method.

URL : PUT http://localhost/my_drupal_apps/services/rest/node/7

I am editing page content.
So I have enabled "edit any page content" permission for all users.

Still its throwing Unauthorized: access denied.

Can anyone please help me how to figure out this issue.

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: