message: Add upload method
diff: @@ -611,32 +611,35 @@ function Facebookbot(configuration) {
  };
  var attachment_upload_api = {
  - upload: function(attachment) {
  + upload: function(attachment, cb) {
  var message = {
  attachment: attachment
  };
  - facebook_botkit.api.attachment_upload.postAPI(message);
  - },
  - postAPI: function(message) {
  +
  request.post('https://' + api_host + '/v2.6/me/message_attachments?access_token=' + configuration.access_token,
  { form: message },
  function(err, res, body) {
  if (err) {
  - facebook_botkit.log('Could not configure messenger profile');
  + facebook_botkit.log('Could not upload attachment');
  + cb(err);
  } else {
  var results = null;
  try {
  results = JSON.parse(body);
  } catch (err) {
  - facebook_botkit.log('ERROR in messenger profile API call: Could not parse JSON', err, body);
  + facebook_botkit.log('ERROR in attachment upload API call: Could not parse JSON', err, body);
  + cb(err);
  }
  if (results) {
  if (results.error) {
  - facebook_botkit.log('ERROR in messenger profile API call: ', results.error.message);
  + facebook_botkit.log('ERROR in attachment upload API call: ', results.error.message);
  + cb(results.error);
  } else {
  - facebook_botkit.debug('Successfully configured messenger profile', body);
  + var attachment_id = results.attachment_id;
  + facebook_botkit.log('Successfully got attachment id ', attachment_id);
  + cb(null, attachment_id);
  }
  }
  }
  