Twilio API - 无法将 phone 号码分配给消息服务

Twilio API - Can't assign phone number to Messaging Service

我正在尝试将新创建的 phone 号码分配给来自 Twilio API 的现有消息服务。 到目前为止,这是我的代码:

创建消息服务

$createService = $twilio->messaging->v1->services
  ->create([
    "friendlyName" => "Service",
    "inboundRequestUrl" => "https://example.com/folder/file.php"
  ]
);

$messagingServiceId = $createService->sid;

正在创建 phone 号码并分配给消息服务

$smsNumber = $_POST["smsNumber"];

$addPhoneNumber = $twilio->incomingPhoneNumbers
  ->create([
    "phoneNumber" => $smsNumber,
    "smsApplicationSid" => $messagingServiceId
  ]
);

使用前面的代码,我可以创建消息服务,phone 号码已添加到帐户,但未分配给消息服务。

我在这里错过了什么?

感谢您的帮助。

查看电话号码资源的 Create A Phone Number 代码示例。

<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
// DANGER! This is insecure. See http://twil.io/secure
$sid    = "ACCOUNT_SID";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$phone_number = $twilio->messaging->v1->services("MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                      ->phoneNumbers
                                      ->create("PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // phoneNumberSid
                                      );

print($phone_number->sid);