Question

Okay so, I'm trying to get the facebook name and email of a user (succeed in that), and then use mandrill to email me that info. But for some reason, can't seem to get the name and email address to pass into the params object. (I deleted a lot of the facebook login stuff to make it clearer) Help!!

 $(function() {

    function getCurrentUserInfo() {
      FB.api('/me', function(userInfo) {
        console.log(userInfo.name + ': ' + userInfo.email);
         temp = userInfo.email;
         name = userInfo.name;

        var needed = {
          "name": userInfo.name,
          "email": userInfo.email
        }

         function log(obj) {
          $('#response').text(JSON.stringify(obj));
        }  



var m = new mandrill.Mandrill('key');

// create a variable for the API call parameters
var params = {
    "message": {
        "from_email":"emailf",
        "to":[{"email":"emailg"}],
        "subject": "New email",
        "html": "*|NAME|* has the email *|EMAIL|* ",
        "autotext": "true",
        "track_opens": "true",
        "track_clicks": "true",
        "merge_vars": [
            {
                "rcpt": "emailrep",
                "vars": [
                    {
                        "name": "NAME",
                        "content": "needed["name"]"

                    },
                    {         
                        "name": "EMAIL",
                        "content": "needed["email"]"

                    }
                ]
            }
        ]

    }

};
Was it helpful?

Solution

You're passing strings when you need the variable:

"vars": [
                {
                    "name": "NAME",
                    "content":needed["name"]

                },
                {         
                    "name": "EMAIL",
                    "content": needed["email"]

                }
            ]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top