What Do I Insert Here?

A

Anonymous

Guest
Hello,
I have been given a PHP snippet from my email marketing platform to install on my Wordpress site. The purpose of it is to pass new email subscribers from my site to my 3rd party email marketing platform. The snippet goes a little like this...

*start snippet*

<?php
$url = "INSERTURLHERE";

$data = array(
"method" => "listSubscribe",
"params" => [
"api_key" => "INSERTAPIKEYHERE",
"list_id" => "INSERTLISTIDHERE",
"emails" => [
"BUT WHAT DO I INSERT HERE?"
]
]
);

$options = [
'http' => [
'method' => 'POST',
'content' => http_build_query(array('data' => json_encode($data)))
]
];

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

*end snippet*

I understand what to put in the $url section, the api_key section and the list_id section but I have no idea what to put in the "BUT WHAT DO I INSERT HERE?" email section to pass form input from my Wordpress site. Does anyone have any suggestions? Please bare in mind that my PHP knowledge is shoddy at best.

Looking forward to any advice I can get,

Scoob
 
What text was there originally in the bit that says "BUT WHAT DO I INSERT HERE?"?
 
It was an email in quotation marks:

"email@example.com"
 
So what do you think goes in an array called emails, with an example entry of "email@example.com"?

I'd try one and see what happens.
 
I have tested it with emails surrounded by quotation marks and this passes back whatever string I type within the quotation marks. The goal is not to pass a string, but to pass the input of the form on my website. So it should pass whatever the user types into the form field (hopefully their email address). I'm just not sure what the syntax for that is.
 
So you need to extract the details from a form on your web site, including permission to pass their details to a third party, and send that to a third party API?

Which part of the syntax are you struggling with? the API? or your form?

Were there instructions for use from the supplier of the snippet?
 
Here is their page explaining how the PHP is used. No instructions related to wordpress.

https://help.sender.net/knowledgebase/id-like-to-use-the-api-is-there-anything-to-help-me-get-started/

Here is the page explaining how to pass back a new subscriber but it only explains how to pass back a single email in a string. I need it to pass back whatever string is inputed into my form fields.

https://help.sender.net/knowledgebase/i-want-to-add-a-list-subscriber-via-the-api-how-do-i-do-that/
 
Back
Top