question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PHP issue can not run notie

See original GitHub issue

I’m trying to run notie in my PHP Code but it does not working for me.

<?php

/* ******************************************************** */
/* Please visit the help file to set correctly this file :) */
/* ******************************************************** */

// Set to "mailchimp" or "file"
$STORE_MODE = "mailchimp";

// MailChimp API Key findable in your Mailchimp's dashboard
$API_KEY =  "";

// MailChimp List ID  findable in your Mailchimp's dashboard
$LIST_ID =  "";

// After $_SERVER["DOCUMENT_ROOT"]." , write the path to your .txt to save the emails of the subscribers
$STORE_FILE = $_SERVER["DOCUMENT_ROOT"]."/subscription-list.txt";

/* ************************************ */
// Don't forget to check the path below
/* ************************************ */

require('MailChimp.php');

/* ***************************************************** */
// For the part below, no interventions are required
/* ***************************************************** */
if($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST["email"])) {
	$email = $_POST["email"];
	header('HTTP/1.1 200 OK');
	header('Status: 200 OK');
	header("Content-Type: text/html");

	// Checking if the email writing is good
	if(filter_var($email, FILTER_VALIDATE_EMAIL)) {

		// The part for the storage in a .txt
		if ($STORE_MODE == "file") {

			// SUCCESS SENDING
			if(@file_put_contents($STORE_FILE, strtolower($email)."\r\n", FILE_APPEND)) {

			// ERROR SENDING
			} else {
			}

		// The part for the storage in Mailchimp
		} elseif ($STORE_MODE == "mailchimp") {

			$MailChimp = new \Drewm\MailChimp($API_KEY);

			$result = $MailChimp->call('lists/subscribe', array(
		                'id'                => $LIST_ID,
		                'email'             => array('email'=>$email),
		                'double_optin'      => true,
		                'update_existing'   => true,
		                'replace_interests' => false,
		                'send_welcome'      => false,
		            ));

			// SUCCESS SENDING
			if($result["email"] == $email) {

			// ERROR SENDING
			} else {

			}
		// ERROR
		} else {

		}
	// ERROR DURING THE VALIDATION
	} else {

	}
} else {
	header('HTTP/1.1 403 Forbidden');
	header('Status: 403 Forbidden');
}

echo '<link defer href="https://unpkg.com/notie/dist/notie.min.css" rel="stylesheet">';
echo '<script defer src="../../vendors/jquery/jquery-3.1.1.min.js"></script>';
echo '<script defer src="https://unpkg.com/notie"></script>';
echo '<script defer>
window.notie.alert({ type: "success", text: "Success!", time: 1.5 })
</script>
';

?>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jaredreichcommented, Apr 28, 2017

Ok, that makes much more sense, thanks. I will investigate.

0reactions
BilalReffascommented, Apr 28, 2017
     ¯\_(ツ)_/¯
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I turn off PHP Notices? - Stack Overflow
You can disable notices by setting error reporting level to E_ALL & ~E_NOTICE; using either error_reporting ini setting or the ...
Read more >
PHP Errors: 4 Different Types (Warning, Parse, Fatal, and ...
A warning error in PHP does not stop the script from running. It only warns you that there is a problem, one that...
Read more >
trigger_error - Manual - PHP
trigger_error — Generates a user-level error/warning/notice message ... Trigger error does not trim 1024+ chars length messages if you use your own error...
Read more >
Error Control Operators - Manual - PHP
Note: The @ -operator works only on expressions. A simple rule of thumb is: if one can take the value of something, then...
Read more >
error_reporting - Manual - PHP
Some E_STRICT errors seem to be thrown during the page's compilation process. This means they cannot be disabled by dynamically altering the error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found