0

I currently have a email pop up modal in my magento CMS but I need to hide the api so my script I will keep server side in PHP.

My question is how can I have a phtml that is just a script be imported into magento if that is possible.

this is my script

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.sendgrid.com/v3/marketing/contacts',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS =>'{"list_ids": [
  "fsfsfsfsfsf"
 ],
 "contacts": [
   {
     "email": "[email protected]",
     "first_name": "jffff gih"
   }
 ]
}',
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'Authorization: Bearer jhdfjhhueurheufheo',
    'Content-Type: application/json'
  ),
));

I omitted the api key and list id key for example reasons.

5
  • just to clarify: At what point should the script get executed? Is it like a contact form or something?
    – Mario
    Apr 12, 2021 at 20:53
  • @Mario on site load. It is a email opt in form. So you load website and modal pops up asking you to enter in your name and email
    – Carter
    Apr 13, 2021 at 2:34
  • at that point, the script should already get executed? Or should it be executed, when the customer sends his name and E-Mail address?
    – Mario
    Apr 14, 2021 at 6:52
  • You can find the answer here: magento.stackexchange.com/questions/301627/… Apr 14, 2021 at 9:54
  • @Mario yes the script would not need to run until the user submits
    – Carter
    Apr 14, 2021 at 19:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.