Search code examples
phptwiliommstwilio-php

Twilio - Invalid Content-Type (PHP)


Here is my PHP code for sending the message:

$client = new Services_Twilio($sid, $token);
$client->account->messages->sendMessage(
    "+15625551212",
    "+17145551212",
    "This is a test",
    "http://ovio.us/profile_images/5.png"
);

The Debug Console shows these Response Headers:
Date Fri, 18 Nov 2016 15:00:52 GMT
Server Apache/2.4.23
Last-Modified Fri, 18 Nov 2016 14:36:46 GMT
ETag "bc001d0-260f-541943c54c496"
Accept-Ranges bytes
Content-Length 9743
Content-Type image/png
X-Cache MISS from ip-172-18-20-243.ec2.internal
X-Cache-Lookup MISS from ip-172-18-20-243.ec2.internal:3128

As far as I know image/png is a valid content-type:
https://www.twilio.com/docs/api/rest/accepted-mime-types


Solution

  • Thanks to Marcos' comment, I determined that the saved image had the PNG extension, but wasn't really a PNG file.

    Edit: So what I did was modified my PHP script to convert any uploaded images to PNG using imagepng().