Not sure why you're not using the PHP Toolkit, but here's some PHP that creates a Contact.
First, with the Enterprise SOAP API
// Namespaces
$ns1 = "urn:sobject.enterprise.soap.sforce.com";
$ns2 = "urn:enterprise.soap.sforce.com";
$client = new SoapClient($enterpriseWsdlFile, array (
'trace' => TRUE, // Useful for debugging!
'features' => SOAP_SINGLE_ELEMENT_ARRAYS // Preserve your sanity
));
$header = new SoapHeader($ns2, "SessionHeader", array ('sessionId' => $sessionId));
// $enterpriseUrl has form https://na1.salesforce.com/services/Soap/c/33.0/[ORG_ID]
$client->__setLocation($enterpriseUrl);
$client->__setSoapHeaders($header);
$contact = new stdclass();
$contact->FirstName = 'Jane';
$contact->LastName = 'Doe';
// You can send multiple records in one call by just putting more
// entries in this array
$sObjects = array(
new SoapVar($contact, SOAP_ENC_OBJECT, "Contact", $ns1)
);
try {
$result = $client->create(new SoapParam($sObjects, 'sObjects'));
echo "Created records\n";
foreach ($result->result as $value) {
echo $value->id."\n";
}
// Debug
echo "SOAP Client returned: \n";
print_r($result);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// Debug...
echo "SOAP Request: \n";
print_r($client->__getLastRequest());
echo "\n";
echo "SOAP Response: \n";
print_r($client->__getLastResponse());
echo "\n";
And the same thing, with the Partner SOAP API:
// Namespaces
$ns1 = "urn:sobject.partner.soap.sforce.com";
$ns2 = "urn:partner.soap.sforce.com";
$client = new SoapClient($partnerWsdlFile, array (
'trace' => TRUE, // Useful for debugging!
'features' => SOAP_SINGLE_ELEMENT_ARRAYS // Preserve your sanity
));
// $partnerUrl has form https://na1.salesforce.com/services/Soap/u/33.0/[ORG_ID]
$client->__setLocation($partnerUrl);
$header = new SoapHeader($ns2, "SessionHeader", array ('sessionId' => $sessionId));
$client->__setSoapHeaders($header);
$fields = array (
new SoapVar('Contact', XSD_STRING, null, null, 'type', $ns1),
new SoapVar('Jane', XSD_STRING, null, null, 'FirstName'),
new SoapVar('Doe', XSD_STRING, null, null, 'LastName')
);
// You can send multiple records in one call by just putting more
// entries in this array
$sObjects = array(
new SoapVar($fields, SOAP_ENC_OBJECT, null, null)
);
try {
$result = $client->create(new SoapParam($sObjects, 'sObjects'));
echo "Created records\n";
foreach ($result->result as $value) {
echo $value->id."\n";
}
// Debug
echo "SOAP Client returned: \n";
print_r($result);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// Debug...
echo "SOAP Request: \n";
print_r($client->__getLastRequest());
echo "\n";
echo "SOAP Response: \n";
print_r($client->__getLastResponse());
echo "\n";
What you need is your username and password (the same one you use to access SFMC). You would need to ensure that your user is a "API enabled" first though.
See below from SFMC documentation:
Authenticate with UsernameToken
You can use a Marketing Cloud username and password to authenticate
your calls. UsernameToken authentication is simple but not as secure
as access token authentication.
When setting up the Marketing Cloud user, select API User. For
Marketing Cloud accounts with role-based permissions, select the Role
| Email | Admin | API Access | WebServices API permission. For
accounts with legacy permissions, select the Grant the user access to
the web services permission. Use the Marketing Cloud username and
password to authenticate your SOAP calls in the header.
Sample Header below:
<soap:header>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>XXXXX</Username>
<Password>XXXXX</Password>
</UsernameToken>
</Security>
</soap:header>
Best Answer
This is definitely something wrong with your username and password.Please note you need security token appended to password like password+token to access salesforce unless your IP address is in network access .