Domains are not being added, Whitelist domains facebook messenger extension

試著忘記壹切 提交于 2019-12-08 06:54:33

问题


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);
});


来源:https://stackoverflow.com/questions/43552879/domains-are-not-being-added-whitelist-domains-facebook-messenger-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!