SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:

    HTML Code:
    <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:

    PHP Code:
    $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"
                    
    }
                ], 

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,389
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •