XML-RPC, CCK & Services

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

A job board wants to integrate their job board with our job board, so that posts made to their site are made to ours. We are providing job posts using CCK, and they want to be able to submit & delete posts to our board.

I am wondering what the best strategy for doing this would be? Would it be to extend the node service, or to write a complete new service from the start? The other site is based on Ruby on Rails, so I want to make the API spec as simple as possible (hiding all of this node struct nonsense), to give a request something like this:

<?xml version=”1.0” encoding=”ISO-8859-1” ?>
<job>
      <command>add</ccommand>
      <username>bobsmith</username>
      <password>p455w0rd</password>
      <contact_name>Bob Smith</contact_name>
      <contact_email>bob@smith.com</contact_email>
      <contact_telephone>020 7987 6900</contact_telephone>
      <contact_url>www.smith.com</contact_url>
      <days_to_advertise>7</days_to_advertise>
      <application_email>bob.12345.123@smith.aplitrak.com</application_email>
      <application_url>http://www.url.com/ad.asp?adid=12345123</application_url>
      <job_reference>abc123</job_reference>
      <job_title>Test Engineer</job_title>
      <job_type>Contract</job_type>
      <job_duration>6 Months</job_duration>
      <job_startdate>ASAP</job_startdate>
      <job_skills>VB, C++, PERL, Java</job_skills>
      <job_description>This is the detailed description</job_description>
      <job_location>London</job_location>
      <job_industry >Marketing</job_industry >
      <salary_currency>gbp</salary_currency>
      <salary_from>25000</salary_from>
      <salary_to>30000</salary_to>
      <salary_per>annum</salary_per>
      <salary_benefits>Bonus and Pension</salary_benefits>
      <salary>£25000 - £30000 per annum + Bonus and Pension</salary>
</job>

What's the best way of going about this? I'm guessing create a new server, based upon node service...

Any help much appreciated!

Thanks,
Chris.

Comments

It's just dawned on me that

chrism2671's picture

It's just dawned on me that the code I pasted above is just XML and not an XML-RPC request.

I'm happy to process either... what's the general opinion on the matter?

One day after submitting

chrism2671's picture

One day after submitting this post I realise that it was probably a bit premature and figured most of the stuff out myself- thanks for looking though!

How did you go about doing this in the end?

dsearle's picture

Hi Chris,

I'm working on a similar type requirement. How did you go about building this out?

Regards,

Dave Searle

Just start hacking away at

chrism2671's picture

Just start hacking away at the Services module and try and write a custom plugin- it is very easy once you get into it- services makes the whole thing a doddle. In the end, we didn't implement it as above, rather, we used XML-RPC instead.

However, if you do want to parse a feed like that above, you need to use FeedAPI + Extensible Feed Parser / Mapper. That should do the trick just nicely without any coding, including tying to CCK.

Broadbean integration

vaccinemedia's picture

I recognise your xml post as coming from Broadbean. I'm in the process of trying to achieve the same thing myself. I have services installed and also have xml-rpc checked in the modules section of the website. I've created a test service and have successfully posted a simple page node using the examples elsewhere on this website. I'm at a brick wall though with cck fields. How was it that you achieved the integration? Did you write a custom plugin or get Broadbean to write a custom xml feed? And if you wrote aplugin do you have a starting point / page / tutorial to have a look at? Thanks.

Well spotted, it is

chrism2671's picture

Well spotted, it is Broadbean's spec. In all honesty, I don't remember exactly which integration this was we were building but we don't use anything like it today. XML-RPC isn't massive in the job board industry; generally speaking, everyone posts an URL with XML formatted job posts and it's up to us to parse them several times a day, in a similar way to the way Drupal's aggregator works.

That makes sense. I was

vaccinemedia's picture

That makes sense. I was actually thinking of taking their posts and using a script to build up a csv file which would be picked up using the feeds module so it would be a two step process:

Broadbean > script > csv > feeds > nodes

Unfortunately I'm stuck with this Broadbean integration. Got to have it sorted asap because they take up to 6 weeks at their end to either create custom xml posts or run the testing and make it go live. Anything you can point me in the right direction with? Do I have to make them create custom xml posts or can I actually work with their default?

Thanks :)

any progress

don1967's picture

hi Vaccinemedia

Did you make any progress with the broadbean integration?

I have the same requirements and a little stuck as to the best way to integrate a solution.

Any guidance you can offer would be much appreciated.

Steve

Broadbean integration

don1967's picture

Hi Chris

What was your solution in the end for this.?

I have got to create a service ( i think ) to receive Broadbean posts in XML format ( as your example ) and add/delete/update to our job board.

In your response, were you indicating that you were able to achieve this by way of XML-RPC or that you need to use FeedAPI + Extensible Feed Parser / Mapper.

ANy chance you could give a lamen terms step process in how to achieve this? Im relatively new to drupal and although can php code im not that familiar with the countless module and stuff that available for all this.

Much appreciated

Steve

I ended up writing a custom

vaccinemedia's picture

I ended up writing a custom module to handle the task of creating the necessary job nodes from the xml posts. In fact it was my first custom module for Drupal 6 and has been re-written as part of the Drupal 7 version of the website. I can post the code up when I've written more comments in the code to highlight how it works :) Also what I've written so far could be the basis of a fully developed Broadbean module by using variables to handle the field mappings but that's out of my level of skills at the moment but it's certainly possible to be achieved.

services module with XML-RPC

don1967's picture

Yeah i didnt think of that although i seem to be on the path of using the services module with XML-RPC although it's a minefield finding the correct documentation which is always sparce if your not a drup expert lol

Anymore code or input you can offer would always be appreciated.

Thanks very much for replying

Steve

OK I've committed the latest

vaccinemedia's picture

OK I've committed the latest version to my sandbox:
https://www.drupal.org/sandbox/vaccinemedia/1796140

Hopefully what's in there will be of help. All the fields are hard coded but essentially what the module does is:
Adds a table for logs which can be examined if anything goes wrong
Listens on the URL /broadbean/add although with it using CRUD it could be updated to be simply /broadbean or /broadbean/process etc..
Checks login details supplied in the xml post and if this matches the credentials of a pre-added user of username "broadbean" progresses with the CRUD operation, logs the outcome and adds a message into watchdog
Adds a block for anonymous users which you can place anywhere you like telling them they need to log in to apply for the job based on your own block placement limited to anonymous users

I created the application functionality using an entity form and the entity reference current module:
https://www.drupal.org/project/entityreference_current

The form is a single form which is added to all job nodes as a block but only visible to logged in users (hence the login block above for anonymous users). The form has a hidden entity reference field which references the current job node being viewed. Using rules I was able to execute a rule on submitting the entity form which loads the contents of the current submitted form and the user who submitted the form and compiles all of this into an email which is sent to the email address associated with the job for tracking. The contents of the form being the job being applied for (title), the username, first name and last name and email address of the user applying along with a comment field and also attaching their CV (pdf) as a file attachment.

wicked

don1967's picture

Thanks so much for posting this.

This broadbean project is the next two weeks of my time so ill be back to post to you any thoughts, improvements or other stuff i discover as work through it.

Cheers Mucho appreciated

Posting XML to broadbean/add

don1967's picture

HI vaccinemedia

Just been looking in more depth into your code.

I can clearly see what you are doing however i am a little perplexed how i can test this by sending an XML post to the url broadbean/add

Have you any thoughts on this?

Given that Broadbean will be using in this way i am obviously needing to replicate this functionality.

Sorted

don1967's picture

Hi

Sorted issue
Ive found a XML poster for such an issue.

Services

Group organizers

Group categories

Group notifications

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

Hot content this week