Key takeaways

  • You can send emojis
  • Emojis must be URL-encoded in the request payload
  • Review our examples, but build and test sending emojis in your application

Yes, you can send emojis 

Who knew that a visual phenomenon from 1970s pop culture would morph into an important part of the modern electronic lexicon? The ubiquitous smiley face has evolved into hundreds of different images that appear in almost every form of electronic communication. Emojis are everywhere.

Zipwhip’s API has the capability to send emojis. However, encoding emojis must be done carefully or they won’t be sent successfully.

Encoding emojis

Encoding emojis is not difficult, but it must be done exactly as described. You must URL-encode the emoji as part of the message request payload, not as part of the message body payload. If you encode the emoji as part of the request payload, then the emoji is sent successfully. If you encode the emoji as part of the message-body payload, then the process fails.

The following is an example of a request payload that includes a URL-encoding for an emoji:

curl ‘http://api.zipwhip.com/message/send’ -H ‘Content-Type: application/x-www-form-urlencoded; charset=UTF-8′ –data session=[session] –data contacts=[number] –data body=’I am sending an emoji through Zipwhip! %F0%9F%98%80’

The following is an example of the smiley face emoji being sent using cURL:

curl ‘http://api.zipwhip.com/message/send’ -H ‘Content-Type: application/x-www-form-urlencoded; charset=UTF-8′ –data session=asdfasdf-asdf-asdf-asdf-asdfasdfasdf:12345679 –data contacts=+10123456789 –data body=’I am sending an emoji through Zipwhip! %f0%9f%98%80’ –trace-ascii –
== Info:   Trying 208.69.95.81…
== Info: TCP_NODELAY set
== Info: Connected to api.zipwhip.com (208.69.95.81) port 80 (#0)
=> Send header, 177 bytes (0xb1)
0000: POST /message/send HTTP/1.1
001d: Host: api.zipwhip.com
0034: User-Agent: curl/7.51.0
004d: Accept: */*
005a: Content-Type: application/x-www-form-urlencoded; charset=UTF-8
009a: Content-Length: 144
00af:
=> Send data, 144 bytes (0x90)
0000: session=asdfasdf-asdf-asdf-asdf-asdfasdfasdf:12345679&contacts=
0040: +10123456789&body=I am sending emojis through Zipwhip! %F0%9F%98%80
0080: %80
== Info: upload completely sent off: 144 out of 144 bytes
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.1 200 OK
<= Recv header, 15 bytes (0xf)
0000: Server: nginx
<= Recv header, 37 bytes (0x25)
0000: Date: Wed, 12 Jul 2017 13:59:10 GMT
<= Recv header, 46 bytes (0x2e)
0000: Content-Type: application/json;charset=UTF-8
<= Recv header, 28 bytes (0x1c)
0000: Transfer-Encoding: chunked
<= Recv header, 24 bytes (0x18)
0000: Connection: keep-alive
<= Recv header, 2 bytes (0x2)
0000:
<= Recv data, 206 bytes (0xce)
0000: c3
0004: {“success”:true,”response”:{“fingerprint”:”4233621183″,”root”:”8
0044: 85136453441445888″,”tokens”:[{“message”:”885136453441445888″,”fi
0084: ngerprint”:”4233621183″,”device”:123456789,”contact”:4243037903}
00c4: ]}}
00c9: 0
00cc:

Example code = server perspective

POST /message/send HTTP/1.1
Host: f8b42c5b.ngrok.io
User-Agent: curl/7.51.0
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 144
X-Forwarded-For: 166.211.237.150
session=asdfasdf-asdf-asdf-asdf-asdfasdfasdf:12345679&contacts=+10123456789&body=I am sending an emoji through Zipwhip! %F0%9F%98%80

Test sending emojis with your software

It’s easy enough for you to copy and paste our examples, and then test sending an emoji. But all that proves is that you know how to copy and paste. Instead, encode the emoji you send the software language that you’re using in your application or system. Doing so is a better test of applying the concept of encoding the emojis in the request payload than copying and pasting our cURL example.

Testing the concept of encoding in the request payload in the language and application that you’re using also helps Zipwhip better troubleshoot any issues you encounter. We support the use of our API in a variety of languages and environments.

 

Alan Capps

Alan Capps

Alan Capps is a Solutions Engineer at Zipwhip. Zipwhip compliments their software with an API to extend the power of texting. Alan works with customers to implement full-feature texting solutions that blend the power of conversational texting and automated messaging.
Alan Capps