Drupanium = Drupal, Services and Titanium Studio documented

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
lelizondo's picture

Just to let everyone know about a project I started a while ago. Drupanium is a distribution and an app with code and documented examples on how to integrate Drupal, Services and Titanium Studio.

There's also some documentation about the Services REST API.

http://drupanium.org

I hope you like it.

Comments

Wow! Thanks for sharing!

jaspher's picture

Wow! Thanks for sharing!

ig: @thejaspher
tw: @jaspher

Very cool, great work!

gbernier's picture

Very cool, great work!

Nice work!

Great work

7wonders's picture

Will be giving it a try these next few days. Just what is needed!

Bitchin!

philosurfer's picture

I got this up and running in about 15 minutes over a burrito?!


          "we are the cult of personality."

Test Devices?

colinafoley's picture

What devices is everyone using?

I had to switch some of the xhr setRequestHeader lines in order to get the build to work on my Android 2.3.3 device. Even with that, I can't seem to log in through the Android app. I don't get any messages or anything when I enter my api.drupanium.org username/password and hit login.

XHR setRequestHeader

mccrodp's picture

Firstly, thanks a lot Luis for making this distro available, great work!

I too am interested in getting this working on Android. What changes did you make to get this functioning?

I have made a brief post on Drupanium, where I have documented some of my findings so far.

Any help is greatly appreciated.

Paul

I haven't really tested it

lelizondo's picture

I haven't really tested it with Android. With iOS you shouldn't have any problems.

Luis

Well done

iaminawe's picture

Looks great - cant wait to try it

Thanks for your work on this
Gregg

This is exactly what i was

allandk's picture

This is exactly what i was looking for. Great.

Great! Login issue

amirtaiar's picture

Thank you! This project is the best kickstrat..

I am working with the Iphone and having error each time I am trying to Log-in.

How can I solve this?

Amir Taiar | Partner & CTO at Reasonat

Thanks.I just got news that

lelizondo's picture

Thanks.

I just got news that Titanium changed the API and Drupanium is broken in some circunstances.

This happens with D6 (and probably with D7 too).
This also happens with POST operations (login is a POST operation).
The problem is not a Services/Drupal thing (I checked with Poster).

You can solve the problem by moving the xhr.setRequestHeader after xhr.open and before xhr.send

Something like this:

var xhr = Titanium.Network.createHTTPClient({timeout: 5000});
xhr.onload = function() {
  // do something
}
xhr.open(type, uri);
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xhr.send();

Luis

[Drupal 7] I have guessed you

amirtaiar's picture

[Drupal 7]
I have guessed you are talking aboit the login.js file.
So I have modified it this way:

<?php
  
// Open the connection using POST
 
xhr.open("POST",url);

  
xhr.setRequestHeader('Content-Type','application/json; charset=utf-8');

  
// Send the connection and the user object as argument
xhr.send(user);
?>

Is that what you mean?
Cause it's yet not working...

Thank you!

Amir Taiar | Partner & CTO at Reasonat

Do you have plan on commit

amirtaiar's picture

Do you have plan on commit this changes soon?
Since I guess there must be more.

Amir Taiar | Partner & CTO at Reasonat

Join Drupanium community now!

utneon's picture

Hello guys! drupanium.org community is now open for collaboration! Please help us out by committing updates in github. Let's try to reach more users to get this project going! We have great plans for drupanium! I've joined the drupanium team to help luis in this project but we are looking for more motivated developers to be part of the project.

Announcing Drupanium framework!

utneon's picture

We are evolving the drupanium project into a framework for titanium sdk. Visit the blog for more information!

drupanium.org/blog

Drupanium framework (First Look)

utneon's picture

You can have a first look at the drupanium framework being developed (screencast). Please contribute back with code fixes, improvements and suggestions.

http://drupanium.org/blog/utneon/drupanium-framework-first-look-screencast

Can't login on Android

marcus178's picture

I have an app working fine on IOS where the user can login, but on Android when the user logs in a Session is returned as normal but after that i just get errors like

[INFO][TiHttpClient( 1267)] (TiHttpClient-16) [4,64534] Sending error Unauthorized: Access denied for user 0 "anonymous"

as if I'm not actually logged in. I'm at a complete loss as to what's going on and why it's not working.

Has anyone had any success with loging in on Android?

user/login.json

bob.sims's picture

Hello marcus178,

Check out this gist for an example I got working with Android using D6 and Services 3.

I went through the same headache you're probably going through. It appears you can only send the user login credentials as a standalone HTTP POST request, and you must wait for the response before you send a request to create content or view privileged node, etc. Titanium seems to do pretty well managing the session cookie automagically, but it took me a while to figure out that Drupal won't recognize the app as logged in until after it has time to return the login response.

You could do this by having separate windows in your app, one to login and another to post or view content, etc. I fake it in my example by using the setTimout() method instead, only for demo purposes, with all data getting dumped to the console.

Also, in my example I use custom events to pass the data asynchronously, but I've since learned that callback functions would be a better technique.

Let us know if you make progress. Hope this helps.

Bob

Thanks for the response. One

marcus178's picture

Thanks for the response. One of the problems I have found is that when using

xhr.setRequestHeader('Content-Type','application/json; charset=utf-8');

which is alway recommended I can't login, i get an error of

[INFO][TiHttpClient( 489)] (TiHttpClient-4) [2,19108] Sending error Not Acceptable: There is no user with ID login.

If I remove it I can login.

Also I run system/connect.json when the app starts to detect if the user is already logged in and on android it always returns a uid of 0

Partly resolved

marcus178's picture

OK I have managed to get system/connect.json working by sending the cookie header like this

xhr.open("POST", url);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.setRequestHeader("Cookie", Titanium.App.Properties.getString("userSessionName") + '=' + Titanium.App.Properties.getString("userSessionId"));
xhr.send();

However if I try the same thing for example to logout, I just get an error saying the user isn't logged in even though they are

http://drupanium.org seems to

SocialNicheGuru's picture

http://drupanium.org seems to be down (12/20/14)

drupanium.org down

utneon's picture

Seems like the owner of the project is not supporting the project anymore.