0

您好,我正在使用 RingCentral API 发送 SMS 和 MMS 并遵循文档,但它在服务器上给了我错误,因为它在本地系统上运行良好。

“客户端错误:POST https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/sms导致400 Bad Request响应”。

function send_mms($rcsdk,$platform,$fromNumber){

try{
    
   $RECIPIENT = '#########';
  
    
    $body = array(
             'from' => array ('phoneNumber' => $fromNumber),
             'to' => array(
                      array('phoneNumber' => $RECIPIENT)
                    )
           );
    $request = $rcsdk->createMultipartBuilder()
        ->setBody( $body )
        ->add(fopen(__DIR__.'/iphone.png', 'r'))
        ->request('/account/~/extension/~/sms');
    $r = $platform->sendRequest($request);
    print_r ("MMS sent. Message status: " . $r->json()->messageStatus . PHP_EOL);
}catch(\RingCentral\SDK\Http\ApiException $e) {
  //print '  Message: ' . $e->getMessage() . PHP_EOL;
  var_dump($e->getCode());
  var_dump($e->getMessage());
  var_dump($e->apiResponse()->response());
}
}
4

0 回答 0