我正在按照Twilio教程(HERE)将语音和短信添加到我的导轨4并继续收到相同的错误... A' To'电话号码是必需的。我想我有一个数字定义...不?我在下面列出了所有相关代码。先感谢您。还要注意,client_phone是表格中的一列......用户输入了client_phone,然后点击该按钮进行分享。
控制器:
Vector3[] defaultPos;
Vector3[] defaultScale;
Quaternion[] defaultRot;
Transform[] models;
//Attach Button from the Editor
public Button resetButton;
void Start()
{
//Call to back up the Transform before moving, scaling or rotating the GameObject
backUpTransform();
}
void backUpTransform()
{
//Find GameObjects with Model tag
GameObject[] tempModels = GameObject.FindGameObjectsWithTag("Model");
//Create pos, scale and rot, Transform array size based on sixe of Objects found
defaultPos = new Vector3[tempModels.Length];
defaultScale = new Vector3[tempModels.Length];
defaultRot = new Quaternion[tempModels.Length];
models = new Transform[tempModels.Length];
//Get original the pos, scale and rot of each Object on the transform
for (int i = 0; i < tempModels.Length; i++)
{
models[i] = tempModels[i].GetComponent<Transform>();
defaultPos[i] = models[i].position;
defaultScale[i] = models[i].localScale;
defaultRot[i] = models[i].rotation;
}
}
//Called when Button is clicked
void resetTransform()
{
//Restore the all the original pos, scale and rot of each GameOBject
for (int i = 0; i < models.Length; i++)
{
models[i].position = defaultPos[i];
models[i].localScale = defaultScale[i];
models[i].rotation = defaultRot[i];
}
}
void OnEnable()
{
//Register Button Events
resetButton.onClick.AddListener(() => resetTransform());
}
void OnDisable()
{
//Un-Register Button Events
resetButton.onClick.RemoveAllListeners();
}
路线:
def share_over_sms
twilio_sid = ENV["TWILIO_ACCOUNT_SID"]
twilio_token = ENV["TWILIO_AUTH_TOKEN"]
twilio_phone_number = ENV["TWILIO_PHONE_NUMBER"]
@twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token
@twilio_client.account.sms.messages.create(
:from => "+1#{twilio_phone_number}",
:to => @client_phone,
:body => "This is a test."
)
end
查看:
get "share_over_sms"
错误:
答案 0 :(得分:1)
listing_collection_params["client_phone"]
参数中使用@client_phone
代替:to
并使用@twilio.messages.create
?不推荐使用API中的.sms.messages
端点。
我还建议您查看来自this one等教程的生产就绪代码示例,以比较Rails设置。