4 Replies Latest reply on Jul 2, 2010 2:57 PM by Albert S.

    accepting a submitted HTTP POST from a URL




      I have a recruitment website that needs to be able to accept jobs from another website:


      ----------- Message From the 3rd party jobsite -----------

      "The way our system works is to submit a HTTP POST to a URL on your site, this will be sent each time a user posts a new advert.

      XML for the individual advert will be found in the body of the POST.


      You will need to set up a page to receive the XML from us, then your process will update the underlying database."




      At the moment I have a ADDT developed insert record form page. Is this easy to acheive? If so how? Ive looked through my existing page at the form action, but getting no clues there:


      <form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">


      ...any help/advice gratefully received.

        • 1. Re: accepting a submitted HTTP POST from a URL
          Albert S.



          From what it sounds like your actual form on your site is irrelevent since they are sending you the data directly you just need to capture it, process it then have it update your database. Correct?

          • 2. Re: accepting a submitted HTTP POST from a URL
            Albert S. Level 3


            So you create a form based on the POST values they are sending you. Once the form is created and working internally you can actually delete the form itself or not it really doesnt matter.


            In the code that gets created you will see the register triggers code that looks something like this... ie: example


            // Make an insert transaction instance
            $ins_media = new tNG_multipleInsert($conn_db);
            // Register triggers
            $ins_media->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
            $ins_media->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
            $ins_media->registerTrigger("END", "Trigger_Default_Redirect", 99, "../includes/nxt/back.php");


            what you want to pay attention to is the "STARTER" if you notice it says POST with the value KT_Insert1. That value is tied to the submit button (form) which basically says if you hit the submit button and POST the value KT_Insert1 to go ahead and run the series of actions such as form validation then insert data then redirect to page when done.


            Well the KT_Insert1 will not be in the POST data that the 3rd party is sending you; you will need to change that value to match some data that is being sent from them. (make sense?).

            That should at least cover the POST data they are sending. If in the body of the POST data they are sending additional XML then that will have to be processed after. Which then we can discuss further.



            • 3. Re: accepting a submitted HTTP POST from a URL
              lazlo Level 1

              thank you for taking the time to reply, very kind. I think I understand... can I change the KT_Insert1 to be predefined?

              • 4. Re: accepting a submitted HTTP POST from a URL
                Albert S. Level 3

                If they send post data to your form,


                Field1 = some data

                Field2 = some data

                Field3 = some data


                the POST value will be Field1, Field2, Field3 so then you can change the STARTER to something like...


                $ins_media->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "Field1");


                So then when the code gets the POST data Field1 it triggers the validation, inserting and redirecting process. If it does not recieve the Field1 POST value it will bypass that code and not trigger anything or it might error. (cant remember what the form does when the POST data that is not accurate comes in)