Create VCard and send via Twilio

I am writing a Twilio + Parse application that allows users to share their contact information via SMS. I have a Vcard sample as a string in javascript:

  message = '';
  message += 'BEGIN:VCARD';
  message += 'BDAY;VALUE=DATE:1963-09-21';
  message += 'VERSION:3.0';
  message += 'N:Stenerson;Derik';
  message += 'FN:Derik Stenerson';
  message += 'ORG:Microsoft Corporation';
  message += 'ADR;TYPE=WORK,POSTAL,PARCEL:;;One Microsoft Way;Redmond;WA;98052-6399;USA';
  message += 'TEL;TYPE=WORK,MSG:+1-425-936-5522';
  message += 'TEL;TYPE=WORK,FAX:+1-425-936-7329';
  message += 'EMAIL;TYPE=INTERNET:deriks@Microsoft.com';
  message += 'END:VCARD';
  message += 'BEGIN:VCARD';
  message += 'VERSION:3.0';
  message += 'N:Ganguly;Anik';
  message += 'FN:Anik Ganguly';
  message += 'ORG: Open Text Inc.';
  message += 'ADR;TYPE=WORK,POSTAL,PARCEL:;Suite 101;38777 West Six Mile Road;Livonia;MI;48152;USA';
  message += 'TEL;TYPE=WORK,MSG:+1-734-542-5955';
  message += 'EMAIL;TYPE=INTERNET:ganguly@acm.org';
  message += 'END:VCARD';
  message += 'BEGIN:VCARD';
  message += 'VERSION:3.0';
  message += 'N:Moskowitz;Robert';
  message += 'FN:Robert Moskowitz';
  message += 'EMAIL;TYPE=INTERNET:rgm-ietf@htt-consult.com';
  message += 'END:VCARD';

And I'm trying to figure out how to send this to a phone number in the form of vcard so that the phone detects it instead of text.

I have a method:

function respondWithMessage(message, response) {
  response.set('Content-Type', 'text/xml');
  var xmlVersion = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n';
  message = '<Message>\n' + message + '\n</Message>';
  message = '<Response>\n' + message + '\n</Response>';
  message = xmlVersion + message;
  response.send(message);
}

With which I can send text messages. Twilio states in its documentation that text / vcard messages are supported here: https://www.twilio.com/docs/api/rest/accepted-mime-types But I couldn’t get it working. Could you give an example of how to send this VCard via SMS with Twilio? Thanks!

+4
2

Twilio . , TwiML, API .

Parse.com :

// Require and initialize the Twilio module with your credentials
var client = require('twilio')('ACCOUNT_SID', 'AUTH_TOKEN');

// Send an SMS message
client.sendSms({
    to:'to', 
    from: 'from', 
    body: 'Hello world!',
    mediaUrl: your-vcard-url
  }, function(err, responseData) { 
    if (err) {
      console.log(err);
    } else { 
      console.log(responseData.from); 
      console.log(responseData.body);
    }
  }
);

, , , , your-vcard-url' is accessible by Twilio, and that its mime type is set to be text/vcard '.

, vcard , Twilio, vcard, .

URL- vcard . ,

+5

Twilio, , curl, :

curl -X POST https://api.twilio.com/2010-04-01/Accounts/<acc>/Messages.json \
--data-urlencode "Body=Your Heart Health Coach contact card" \
--data-urlencode "MediaUrl=https://mighty-health-assets.s3.amazonaws.com/vcf/James%20Li.vcf" \
--data-urlencode "From=<from>" \
--data-urlencode "To=<to>" \
-u <auth>:<auth>

vCard, , .

, iOS/Android, .

iOS , , filename Content-Type,

Content-Type: inline; filename="<You file name>.vcf"
Content-Disposition: text/x-vcard
Cache-Control: no-cache

  1. Twilio ,
  2. , VCF,

, , ,

Twilio Caching

, : https://support.twilio.com/hc/en-us/articles/360024716314-How-Can-I-Change-the-Cache-Behavior-or-Message-Media-Files-

, Twilio VCF, , , , .

0

Source: https://habr.com/ru/post/1608177/


All Articles