Weird PHP error in the latest WebServices documention

Use this forum for all questions related to the source code of OpenEMM

Moderator: moderator

Weird PHP error in the latest WebServices documention

Postby sam2de » Mon Jan 09, 2017 8:35 pm

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);)

Code: Select all

<?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";
?>


Any thoughts? Thanks in advances.
sam2de
 
Posts: 1
Joined: Fri Jan 06, 2017 9:53 pm

Re: Weird PHP error in the latest WebServices documention

Postby mdoerschmidt » Fri Jan 13, 2017 8:39 am

Hi!

There is an error in the documentation.

In the line
Code: Select all
$subscriberId = $client->value;

the identifier $client is wrong. It must be named $result.
mdoerschmidt
 
Posts: 18
Joined: Fri Jan 04, 2013 8:55 am


Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron