Jump to content

PHP - SOAP


starkec

Recommended Posts

Hey guys,

I'm trying to use PHP and nuSOAP to send information from my form to this web service on directTrack. The web service even gives me details on what the web service needs from the soap: http://secure.directtrack.com/api/soap.php# (its the addAffiliate one listed). So this gives the SoapAction, endpoint, etc.

 

I have this code below, but I can't seem to get it working. Am I in the right direction?

 

<?php

require_once('lib/nusoap.php');

 

$endpoint = 'http://secure.directtrack.com/api/soap.php';

$namespace = 'http://soapinterop.org//';

$soapAction = 'http://secure.directtrack.com/api/soap.php/addAffiliate';

 

// Build our paremeter array

$FIELDS = array();

 

$FIELDS['client'] = 'testing';

$FIELDS['password'] = 'test';

$FIELDS['email'] = $_POST['email'];

$FIELDS['first_name'] = $_POST['first_name'];

$FIELDS['last_name'] = $_POST['last_name'];

$FIELDS['company'] = $_POST['company'];

$FIELDS['pwd'] = $_POST['pwd'];

$FIELDS['address'] = $_POST['address'];

$FIELDS['address2'] = $_POST['address2'];

$FIELDS['city'] = $_POST['city'];

$FIELDS['state'] = $_POST['state'];

$FIELDS['country'] = $_POST['country'];

$FIELDS['zip'] = $_POST['zip'];

$FIELDS['phone'] = $_POST['phone'];

$FIELDS['fax'] = $_POST['fax'];

$FIELDS['tax_id'] = $_POST['tax_id'];

$FIELDS['website'] = $_POST['website'];

$FIELDS['website2'] = $_POST['website2'];

$FIELDS['website3'] = $_POST['website3'];

 

$soap = new soapclient($endpoint, 'wsdl');

$result = $soap->call('addAffiliate', array('parameters' => $FIELDS), $namespace, $soapAction);

 

echo "request: ".$client->request;

if ($client->fault) {

      echo "SOAP error: ".$result['faultstring'];

        print_r($result);

} else {

      $err = $client->getError();

      if ($err) {

                echo "SOAP error: ".$err;

        }

        else {

                print_r($result);

}

}

 

 

?>

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.