What Do I Insert Here?

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
ScoobyDoo47
New php-forum User
New php-forum User
Posts: 4
Joined: Mon May 04, 2020 7:37 am

Wed May 06, 2020 7:20 am

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
User avatar
hyper
php-forum GURU
php-forum GURU
Posts: 1222
Joined: Mon Feb 22, 2016 5:52 pm

Wed May 06, 2020 7:54 am

What text was there originally in the bit that says "BUT WHAT DO I INSERT HERE?"?
ScoobyDoo47
New php-forum User
New php-forum User
Posts: 4
Joined: Mon May 04, 2020 7:37 am

Wed May 06, 2020 10:20 am

It was an email in quotation marks:

"email@example.com"
User avatar
hyper
php-forum GURU
php-forum GURU
Posts: 1222
Joined: Mon Feb 22, 2016 5:52 pm

Wed May 06, 2020 10:51 am

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.
ScoobyDoo47
New php-forum User
New php-forum User
Posts: 4
Joined: Mon May 04, 2020 7:37 am

Wed May 06, 2020 11:13 am

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.
User avatar
hyper
php-forum GURU
php-forum GURU
Posts: 1222
Joined: Mon Feb 22, 2016 5:52 pm

Thu May 07, 2020 12:33 pm

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?
ScoobyDoo47
New php-forum User
New php-forum User
Posts: 4
Joined: Mon May 04, 2020 7:37 am

Sat May 09, 2020 3:18 am

Here is their page explaining how the PHP is used. No instructions related to wordpress.

https://help.sender.net/knowledgebase/i ... t-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 ... i-do-that/
Post Reply