Results 1 to 7 of 7

 

Thread: wordpress site posting a lead to an api

  1. #1
    keano's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2004
    Location
    Wirral
    Posts
    152
    Thanks
    14
    Thanked 17 Times in 15 Posts


    Hi All,

    Does anyone have a solution for a wordpress based site that needs to do an automated HTTP post of a web generated lead (with only a couple of form variables, such as name, phone, email, etc) to an API when leads are generated.

    Been searching around for some code, but I'm drawing a blank big time. I'm no expert coder but if someone had a code base, I'm sure I could work it out.

    Thanks,

    Mike

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Nov 2004
    Location
    Wirral, Merseyside
    Posts
    2,205
    Thanks
    60
    Thanked 112 Times in 86 Posts
    Try scriptmonkey, he's our resident API expert.

  3. #3
    scriptmonkey's Avatar
    Oranges & Lemons

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Worthing
    Posts
    1,607
    Thanks
    112
    Thanked 253 Times in 192 Posts
    So, if I have you right, you have a form on a WP install, from which you want to send the results to an API?
    The trouble with the rat race is that even if you win you're still a rat.
    Time passes. Listen. Time passes. Dylan Thomas
    Ebay Alerts to your inbox

  4. #4
    keano's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2004
    Location
    Wirral
    Posts
    152
    Thanks
    14
    Thanked 17 Times in 15 Posts
    Quote Originally Posted by scriptmonkey View Post
    So, if I have you right, you have a form on a WP install, from which you want to send the results to an API?
    Bang on. We need to get the data that's generated by a webform on a WP install posted to an API with a .aspx url.

  5. #5
    scriptmonkey's Avatar
    Oranges & Lemons

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Worthing
    Posts
    1,607
    Thanks
    112
    Thanked 253 Times in 192 Posts
    I suggest this:

    Create a new template for WP, add all the interaction required in the head of the new template (I'd use cURL to post the details to the API), add a hidden field to the form so that the cURL part is only called when the hidden field is set as a $_POST variable, use that template for the form.

    PHP Code:
    define('POSTURL''http://www.servername.com/APIpage.aspx');
    if(isset(
    $_POST['Email'])) $Email $_POST['Email'];
    if(isset(
    $_POST['Name'])) $Name $_POST['Name'];
    // etc.
    define('POSTVARS''Name=$Name&Email=$Email');

         
    $ch curl_init(POSTURL);
         
    curl_setopt($chCURLOPT_POST      ,1);
         
    curl_setopt($chCURLOPT_POSTFIELDS    ,POSTVARS);
         
    curl_setopt($chCURLOPT_FOLLOWLOCATION  ,1); 
         
    curl_setopt($chCURLOPT_HEADER      ,0);  
         
    curl_setopt($chCURLOPT_RETURNTRANSFER  ,0);  
         
    curl_exec($ch);
         
    curl_close($ch); 
    That kind of thing.
    The trouble with the rat race is that even if you win you're still a rat.
    Time passes. Listen. Time passes. Dylan Thomas
    Ebay Alerts to your inbox

  6. The Following User Says Thank You to scriptmonkey For This Useful Post:

    keano (21-01-11)

  7. #6
    keano's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2004
    Location
    Wirral
    Posts
    152
    Thanks
    14
    Thanked 17 Times in 15 Posts
    Thanks very much for your help - much appreciated!

  8. #7
    Registered User

    Status
    Offline
    Join Date
    Nov 2004
    Location
    Wirral, Merseyside
    Posts
    2,205
    Thanks
    60
    Thanked 112 Times in 86 Posts
    I told you he was our expert!



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2