Including a php string when posting to a json url

Hi there,

I’m posting some data to a json url (mandrill) but i want to also include some php (the generation of a 1 time code) in the html. Not sure how to do this.

The line in question that starts with “html”: - what I want to do is have the following output:

<p>here's your download link: <a href="mylink.php">download song</a>. Enjoy the music!</p>

Here’s what I’ve got so far:

$uri = 'https://mandrillapp.com/api/1.0/messages/send.json';
        $postString = '{
        "key": "MY-KEY",
        "message": {
            "html": "<p>here's your download link: " . "http://" . $_SERVER['HTTP_HOST'] . DOWNLOAD_PATH . "?" . $new; "Enjoy the music!</p>",
            "subject": "Your Free Song Download",
            "from_email": "fromemailaddress@gmail.com",
            "from_name": "My Name",
            "to": [
                {
                    "email": $email,
                    "name": "To Name"
                }
            ],

Create your data as an associative array and use the json_encode() function… it’s much easier and it’ll ensure your url is properly escaped. You’ll also want to remove the semicolon after $new or you’ll get an error.