06 April 2010

Send a vCard in PHP with an SMPP gateway


I was recently asked to write a program that will send a broker's phone number as a vCard to a list of leads. There is a surprising number of pages dedicated to this problem, but no simple solutions. Here's a quick and easy PHP solution to the problem:

$header = "//SCKL23F4 ";
$vcard = bin2hex("BEGIN:VCARD\r\nFN:Cellsmart JHB\r\nTEL;PREF:+27116467353\r\nEND:VCARD\r\n");
$message = $header . $vcard;

Then send the $message using your SMSC SMPP gateway as usual.

The W3C has some notes on the vCard that has a useful example of a card but a Google search should quickly reveal the full standard details.

Just by the way the $header variable is set to //SCKL23F4 because this is a newer format and is supposed to support vCards that need to be sent over two messages.
Tip

No comments:

Post a Comment