PHP Api question

nemesis82

Active Member
Hy guys, are almost 10 year I don't develop in php.. I need to update asap but I have a question ( simple for you ) for api value export. In which way I can export only single value from api response?
Example :
<pre>MailWizzApi_Params Object
(
[_data:MailWizzApi_Params:private] => Array
(
[status] => success
[data] => Array
(
[count] => 3
[total_pages] => 1
[current_page] => 1
[next_page] =>
[prev_page] =>
[records] => Array
(
[0] => Array
(
[subscriber_uid] => oh171hezvxe18
=> nemesis82@example.com
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.'] [FNAME] =>
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.'] [LNAME] =>
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.'] [COUNTRY] =>
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.'] [status] => confirmed
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.'] [source] => web
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.'] [ip_address] =>
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.'] [date_added] => 2018-11-16 19:56:54
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.']
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.']I want only value from email field ( if I can export email value, I can export all other field ) because I need to hash this value and sync it with Mailwizz external platform .
=>
[LNAME] =>
[COUNTRY] =>
[status] => confirmed
[source] => web
[ip_address] =>
[date_added] => 2018-11-16 19:56:54

I want only value from email field ( if I can export email value, I can export all of other field I need ) because I need to hash this value and sync it with Mailwizz external platform .
Thanks for your support.']Thanks for your support.
 
@nemesis82 - that's simple.
PHP:
$response->body
is an object, with a `data` property, so if you do
PHP:
$response->body->data
you will get
PHP:
array(
[count] => ...
[total_pages] => ..
[current_page] => ..
[next_page] =>..
[prev_page] =>..
[records]  => array()
Now, you need to get the records array, because that's where your subscribers are:
PHP:
$response->body->data['records']

Since $response->body->data['records'] is an array of arrays, you can loop through it and get data:
PHP:
foreach ($response->body->data['records'] as $record) {
    echo $record['subscriber_uid'] . ' - ' . $record['LNAME'];
}

That's pretty much it.
 
Hi twisted, thanks for your fast reply.
I've tried with a foreach loop but give me an error :
PHP Warning: Invalid argument supplied for foreach()
Also I've copied / pasted your code ( for any wrong syntax ) and throw me the same error. Surely I wrong in some part :)
 
found the issue :)
This is the correct syntax : ( $response->body['data']['records'] )

foreach ($response->body['data']['records'] as $record) {
echo $record['subscriber_uid'] . ' - ' . $record['EMAIL'];
}

I write here, probably is useful for other users .
Thanks a lot twisted!!
 
Back
Top