Salsa API Project

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

Hey everyone sorry for being MIA for a while there, I've had very little time to pay attention to this project in the last little bit.

However my calendar has cleared up enough that I can get some more work done on this.

I have made some more progress with the api, it now has some functionality to save data back to the database.

I'm working on some documentation for it (ug) and then i'll get the project created and a first release out (for real this time)!

Stay tuned...

Update:

Project has now been created, you can find it here: http://drupal.org/project/salsa_api

6.x-1.x-dev snapshot now available.
5.x-1.x-dev snapshot now available.

This project/release will only contain the api, not the example modules I had earlier (email/campaign modules) because
A: Those were created for testing the api and are not really part of it
B: they should be separate modules with their own releases. You can however download them from here:
5.x - Salsa Email, Salsa Campaign
6.x - Salsa Email, Salsa Campaign

Comments

Updated first post of this

codewatson's picture

Updated first post of this discussion with a link to the project!

This is great news,

laken's picture

This is great news, Daniel.

A month or two ago I took your code, backported the API to Drupal 5, and added saving data back to Salsa for a project I'm working on. I wonder if you'd like to look at that code? It's a little messy probably (deadline client project) but might be helpful. Let me know if you're interested and I'll send you the code.

I'm really pressed for time at the moment, but when I free up a bit I would really like to help out with this project, possibly even co-maintain, or maintain a D5 branch. Are you open to that?

Thanks again, this is really long-awaited (I'm talking years!)

Development snapshot is now

codewatson's picture

Development snapshot is now published, so feel free to take a look at it. Supposedly this will be updated every 12 hours with whatever changes i make, assuming i did it correctly, drupal and cvs is a pain in the butt to understand.....

laken:
I'd love to see what you came up with. I haven't polished the saving side of the api as much as the getting side so it would be good to see how someone else thought of doing it. Right now i have the one function, salsa_api_query, doing both the getting and saving of data, i did make some changes to it since the code that was available a month or so ago so you might want to take a look at it.

I'm totally open to a co-maintainer, i find that i run into roadblocks sometimes and it would be nice to have someone else in which to bounce idea's off of as well as having someone with a different perspective on how we could do things. Do you already have a developer account?

After we get the saving side of the module a bit more fleshed out and stable i think then we could make a 1.0 release, or at least a beta release. Until then only the dev version will be available.

If you have ideas for other modules that would use this api please make them here. While I had created a few rough ones while developing this, i could use some ideas for what people really would need in a module. Also if anyone else whats to take a stab at making their own, let us know!

Again, please try out the module and the 2 test modules i have linked in the first post, we really need some testers/feedback!

My organization's new

KevinN's picture

My organization's new website, my first introduction to drupal, is being launched in a couple weeks. Once it is out, I'll have more time to figure out the code and help out a little. I'd be down for testing and bouncing ideas off of. I learn quick but I'm definitely new to these languages. Any help I can provide, just ask.

Good to hear, feel free to

codewatson's picture

Good to hear, feel free to give them a try once you have your site going. I'm open to suggestions for the api as well as any possible drupal modules you think your organization's website could use.

Bugs

KevinN's picture

So I finally got the modules loaded and figured out how to get them to show. I noticed that the links for the emails doesn't work. It just shows: "http://o/xxxx/blastContent.jsp%3Femail_blast_KEY%3Dxxxxxxx" instead of "http://org2.democracyinaction.org/o/xxxx/blastContent.jsp?email_blast_KEY=xxxxxx&t=". Also, it would be nice to be able to format these in some way, allow us to modify the date (ex. excluding the time) and show particular eblasts, instead of all of them (I think tags would be the best route).

Hmm, i'll take another look

codewatson's picture

Hmm, i'll take another look at it and see if i can get it fixed tomorrow sometime, please remember that the email module is just an example so its bound to be buggy. As for the date, unfortunately what you see is exactly how the data is stored in salsa, they dont store it in a format that would allow me to change the format easily. However with some work i'm sure i could finagle it to show itself in a more pleasing format.

By the sounds of it you are interested in an email module, if i made an actual project out of it what features would you like to see in it? What would you use an email module to do? I need some ideas so i know what direction to go in!

For the date info, you could

KevinN's picture

For the date info, you could cut it off at 15 characters to leave off the time. Also, it would be great if it used "Time Sent" rather than the other date fields.
I'm actually using both modules. I don't know if this is possible but it would be nice if the data could be put into a View so I could manipulate the data to match my other Views.
For the email module, I'd like to be able able to choose which emails are shown. That way, if I have a few groups, I can show that group's email on their group page and not have to show all the other, non-related emails. I also wonder if it can show a teaser or something or be able to add a template.
For the campaign module, it would be cool to have a date created field. I don't know if that is set to show only current campaigns or not.
That's all I can think of right now but I'm sure I'll have more later.

For the Campaign module:

KevinN's picture

For the Campaign module: Another item: the "more link" checkbox doesn't function. I can't turn off the "more items" thing.
Also, the date only shows up on the more page, not the teaser block.

@KevinN: I've made a few

codewatson's picture

@KevinN:

I've made a few quick fixes to the campaign module to get the more link working and have it show the date in the block as well. I also found a way to format the date better, but havnt had a chance to implement it yet, so stay tuned, i may spend some more time on it this weekend. campaign, email (D6 only)

@all:
I'm also in the process of trying to get a simple sync between the drupal user and the salsa supporter, ie, if someone registers on a drupal site, it will automatically add them to salsa as well including password. right now adding them works, but for some reason the password part if they exist in salsa already doesnt seem to work, if they dont exist, it has no problem sticking the password in there... argle...

Backport to Drupal 5 in progress

codewatson's picture

I've created a 5.x branch, it should be available in the next 12 ish hours. I've also back ported the example modules, the links are in the first post.

5.x branch now available

codewatson's picture

5.x branch now available

This is great, Daniel! I've

gengel's picture

This is great, Daniel!

I've started work on some data-sync modules between Salsa and Drupal based on this. I hope to make it public soon to attract more attention / ideas / support. Is this the sort of thing you'd like to see lumped in with the API module itself, or as a separate project?

Also, write support wasn't (initially) working for me - I made a few changes and submitted a patch at http://drupal.org/node/493544

Thanks for the feedback

codewatson's picture

gengel:
Thanks for the feedback. I haven't really spent much time on the saving side of the module yet, but that is my next focus. I'll take a look at the patch you provided. Would it be possible for me to get the data-sync modules your working on so i can have something to test with? At the moment i dont really have anything created myself so it would be useful to have an example to work off of.

As for including it with the api, i'm not sure. My thinking was that this module would be just the communication layer between drupal and salsa, that way if there were any changes to the salsa external api it would hopefully mean that there would only be a need to change this module and not others? I'm totally open to suggestions though, i could use all the help i can get in shaping this thing.

Again, it would be great if i could take a look at what you have come up with so i have something to test out saving data with!

Okay, the current working

gengel's picture

Okay, the current working copy of my module is in /contributions/salsa_supporters in CVS. (The dev version should be on the project page soon - http://www.drupal.org/project/salsa_supporters ) Hope that helps.

Great, i'll look it over. I

codewatson's picture

Great, i'll look it over. I made the changes in your patch as well as fixed a bug with getLeftJoin.sjs/getObjects.sjs where #fields wasn't changed to #include properly, so the include fields were being left out of the query.

Salsa Supporters Sync

gengel's picture

I would also point people looking to sync Drupal user accounts and Salsa supporter objects to my Salsa Supporter Sync module (built on top of Daniel's API!)

It's incomplete, and what's there is VERY rough, but it addresses the user/supporter sync issue Daniel mentioned above...

http://drupal.org/project/salsa_supporters

Just committed a big batch

gengel's picture

Just committed a big batch of changes. Synchronization seems to be working between Drupal/Salsa for fields in supporter and supporter_custom (as well as groups support, which was present before).

Great, i'll take a look at

codewatson's picture

Great, i'll take a look at it!

Minor updates to the API

codewatson's picture

Few minor updates to the api:

  1. Added support for getReport.sjs. (Returns the results of a salsa or user created report)
    This is now functioning, for a while there it was broken on the salsa end of things. Only takes one paramater besides the script name: #fields, which contains the report_KEY you want returned.
  2. Fixed cURL timeout setting (was 10000 seconds instead of 10 seconds).
    This was causing problems if the salsa node site(s) could not be reached, the page would sit there and try to load for 10000 seconds, needless to say this was not intended and dramatically interfered with any page that had a salsa query on it. It will now try to connect for 10 seconds before timing out and allowing the rest of the page to load.
  3. Changed menu setting to have it's own menu block under admin for future modules to add their own setting menus to.
    As I and gengel are creating modules that use the api, it became apparent to me that we would both be creating our own configuration menu options that would appear under the site admin stuff. So I have created a "Salsa" option under the admin area for all salsa configuration menus to land. To get them to appear there you just have to use the path "admin/salsa/your_path".

dev packages should be recreated in 12 hours or so, or grab the updated code directly from the cvs.

update: changes have been ported to D5 as well.

Objects or Arrays? Your preference?

codewatson's picture

So another developer named Sheldon has brought to my attention that the result returned from the salsa_api_query() function doesn't have to be an array. It is now because i didn't realize you could navigate an object with an "-" in the name by surrounding it with {}.

So my question to you is, which do you prefer dealing with, an object or an array?

It's easy enough to cast

gengel's picture

It's easy enough to cast from one to the other, so from a personal perspective, I don't particularly care - you should probably go with what makes the most sense.

I guess the real question is which method is more "Drupal"-y?

Hmm, well as far as i can

codewatson's picture

Hmm, well as far as i can tell drupal uses both in various places, for instance, hook_user() has the parameters: $account, which is an object, and $edit, which is an array.... forms use arrays, so it seems pretty much a hybrid to me. I've done some checking through the drupal forms but haven't found anything that suggests which is better. I did see something about there used to be a function in drupal that would convert an array to an object and vice-versa, but they decided it was inefficient, and instead went with $var = (array)$object, though that only converts the first level elements to an array...

The only advantage i see is keeping it as an object would save some processing power, as we wouldn't need to run the function to convert it. For smaller queries this probably isn't noticeable, but if your query returns a lot of information it might make a difference.

Salsa

Group organizers

Group notifications

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