Menu

#151 PHP error in the latest WebServices documentation

OpenEMM
open
nobody
API (1)
7
2017-01-11
2017-01-10
Sam
No

Hello,
I have been following along making php implementation for the webservices using the latest Webservice-API_2.0_EN-v2.0.16.pdfhttps://sourceforge.net/projects/openemm/files/OpenEMM%20documentation/Documentation%20%28latest%20versions%29/, I'm usling the latest Openemm 2015 as well and using same PHP examples in the documents, and I'm getting a php error "Notice: Array to string conversion in line #x"

below is the code as I get from the documentation, and the php error is pointing at this line ($result = $client->FindSubscriber($data);)

<?php
class KeyValuePair {
public $key;
public $value;
function __construct($key, $value) {
$this->key = new SoapVar(
$key, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$this->value = new SoapVar(
$value, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
}
}
// ***********************************************************************
// Step 1: Setup
// ***********************************************************************
// Include SOAP client class
include('WSSESoapClient.php');
$url = 'write your WSDL URL here';
$username = 'write your username here';
$password = 'write your password here';
// ***********************************************************************
// Step 2: Create SOAP client
// ***********************************************************************
$client = new WsseSoapClient($url, $username, $password);
// ***********************************************************************
// Step 3: Find the subscriber
// ***********************************************************************
$data = array(
"keyColumn" => "email",
"value" => "test@example.com");
$result = $client->FindSubscriber($data);
$subscriberId = $client->value;
if($subscriberId == 0) {
die("Subscriber not found!");
}
// ***********************************************************************
// Step 4: Update subscriber
// ***********************************************************************
$profileFields = array(
new KeyValuePair("firstname", "John"),
new KeyValuePair("lastname", "Doe")
);
$data = array(
"customerID" => $subscriberId,
"parameters" => $profileFields
);
$result = $client->UpdateSubscriber($data);
echo "Updated subscriber\n";
?>

Discussion

  • Markus

    Markus - 2017-01-11

    The only error I can see is in the line

    $subscriberId = $client->value;
    

    The variable $client has to be replaced with $result.

     
    • Sam

      Sam - 2017-01-11

      Thanks Markus, I had it modified it in my code already, but becase of the error I mentioned above"$result = $client->FindSubscriber($data);", the code is not really making the soap call at all.
      I tried different php versions, soap client is enabled and using same code as above.
      Thanks again

       

Log in to post a comment.