message: Add messenger code API
diff: @@ -517,6 +517,40 @@ function Facebookbot(configuration) {
  }
  });
  }
  + },
  + get_messenger_code: function(image_size, cb) {
  + var message = {
  + 'type': 'standard',
  + 'image_size': image_size || 1000
  + };
  + request.post('https://graph.facebook.com/v2.6/me/messenger_codes?access_token=' + configuration.access_token,
  + {form: message},
  + function(err, res, body) {
  + if (err) {
  + facebook_botkit.log('Could not configure get messenger code');
  + cb(err);
  + } else {
  +
  + var results = null;
  + try {
  + results = JSON.parse(body);
  + } catch (err) {
  + facebook_botkit.log('ERROR in messenger code API call: Could not parse JSON', err, body);
  + cb(err);
  + }
  +
  + if (results) {
  + if (results.error) {
  + facebook_botkit.log('ERROR in messenger code API call: ', results.error.message);
  + cb(results.error);
  + } else {
  + var uri = results.uri;
  + facebook_botkit.log('Successfully got messenger code', uri);
  + cb(null, uri);
  + }
  + }
  + }
  + });
  }
  };
  