Output subscriber details not as an array using PHP wrapper

I would like to display user details, each field as a separate parameter and not an array.

I use the PHP sample code from the CM library

$wrap = new CS_REST_Subscribers($ListAll, $ApiKey);    
$result = $wrap->get('test@test.com');
if($result->was_successful()) { var_dump($result); }

The output is just standard array.

This is what I need:

$name = $result->Name;
$email = $result->EmailAddress;
$Customfield1 = $result ->Customfield1;
and so on ...

Can you tell me how the code should look like ?

The user will come to the landing page, I will pass parameters through URL and then I want to display formular with predefined fields, that is I need to have every single value from the array.


tobyb tobyb, 6 years ago

Hey tomasz,

The PHP samples are written to allow you to quickly determine the structure of the returned objects. The result returned from the API call is an instance of CS_REST_Wrapper_Result while the response is the deserialised JSON response. In the samples we use var_dump to show the available properties of the response object, these properties may be accessed just like a normal object member, as you have suggested e.g.

$name = $result->response->Name
$email = $result->response->EmailAddress

For more information about working with objects and arrays, take a look at the PHP manual, specifically here and here.

tomasz, 6 years ago

Super, this is what I need. thanks ;-)

tomasz, 6 years ago

Hey again,

actually it doesn't work with custom fields. I got Undefined index: Phone (this is one of my custom fields) ....

Any suggestions please?

tomasz, 6 years ago

Finally got it ;-)


Thanks for the really solid support guys (David and Toby) ;-)

Mitch, 6 years ago

Hello there

This thread got me half-way—I'm using this $result->response->CustomFields to get to the custom fields—but the x in CustomFields[x] keeps changing because there's a multi-value custom field above it.

The number is always six less than the 10 here:

array(10) {

So maybe there's some trick with math, but otherwise I don't know how to get to the specific custom field I'm after.

Thanks in advance!

PDD2010, 1 year ago

This is quite useful:


But what I would like to do is this:


How to do this ?

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free