If you use the RingCentral PHP SDK to send MMS messages, you don’t need to set the request header. Just follow the sample code as such to send your message. The SDK set the content-type to “multipart/form-data” as you could see.
I can check with the dev guide writer to see what that means. But I know that we support both /form-data and mixed content types.
@PhongVu unfortunately when i use the example from the SDK I get a 400 bad request error. The body of the error response contains <html> that says: bad request cloudfare. When i change the header to multipart/mixed the error disappears (I get the error “This feature is not available” which i expect since this is a development account). Therefore? I thought the issue was with the inccorrect content-type and wanted to double check here
I am sure that it’s because of the sandbox environment which is no longer support SMS/MMS.
This code works perfect for me on production environment.
function send_mms($fromNumber){
global $platform, $rcsdk;
global $RECIPIENT;
try {
$bodyParams = array(
'from' => array( 'phoneNumber' => $fromNumber ),
'to' => array( array('phoneNumber' => $RECIPIENT ) ),
'text' => 'Hello World!'
);
$endpoint = "/account/~/extension/~/mms";
$request = $rcsdk->createMultipartBuilder()
->setBody( $bodyParams )
->add(fopen(__DIR__.'/test.jpg', 'r'))
->request($endpoint);
$resp = $platform->sendRequest($request);
print_r ("SMS sent. Message status: " . $resp->json()->messageStatus . PHP_EOL);
}catch (\RingCentral\SDK\Http\ApiException $e) {
// Getting error messages using PHP native interface
print 'Expected HTTP Error: ' . $e;
print ' Message: ' . $e->apiResponse->response()->error() . PHP_EOL;
}
}
So if you have a production account, please test again.