-->

Domains are not being added, Whitelist domains fac

2019-05-31 13:32发布

问题:

I've been trying to whitelist my domains following the instruction that is given by facebook but nothing is working.

I first tried with curl, the response is {result:"success"} but when I try to list the domains that are whitelisted I am getting {data:[]}

Then I tried using node request module as follow:

request.post("https://graph.facebook.com/v2.6/me/messenger_profile?access_token=sfdlksdfu79r9429049824982342348sjdfsf", {
                "setting_type": "domain_whitelisting",
                "whitelisted_domains": ["https://mydomainw.com", "https://mydomainw.com/profile", "https://sfujyx.com/ofr", "mydomain1.com", "mydomain.com"],
                "domain_action_type": "add"}, function (err, res, body) {
                console.log("Whitelisting domain");
                if (!err) {
                    console.log(body);
                    console.log("Showing the list of whitelisted:");
                    request.get("https://graph.facebook.com/v2.6/me/messenger_profile?fields=whitelisted_domains&access_token=sfdlksdfu79r9429049824982342348sjdfsf", function (err, res, body) {
                        if (!err) {
                            console.log(body);
                        } else {
                            console.log(err);
                        }
                    });
                } else {
                    console.log(err);
                }
            });

Still it bring the same result as curl :

And when I use Facebook Graph Api Explorer tool, here is the error I am getting:

I am really stuck, I don't know what should I do or how people exactly whitelist domain for messenger extension.

What I am doing wrong? why isn't the domains being added?

My project is on Google App Engine.

回答1:

The problem is I was using the App Access Token instead of the Page Access Token, I didn't know the difference.



回答2:

your domain: "https://mydomainw..com" is an invalid domain.

The request should return:

{
  "error": {
    "message": "(#100) whitelisted_domains[0] should represent a valid URL",
    "type": "OAuthException",
    "code": 100,
    "fbtrace_id": "Aq3AVaNVJU9"
  }
}


回答3:

Actually, I didn't use "setting_type" before. This is how I register domains:

var request = require("request");

var options = { method: 'POST',
  url: 'https://graph.facebook.com/v2.6/me/messenger_profile',
  qs: { access_token: 'my_page_token' },
  headers: { 'content-type': 'application/json' },
  body: 
   { whitelisted_domains: 
      [ 
        'https://mydomainw.com',
        'https://ijuugwivbc.localtunnel.me' ] },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});