GET请求适用于CURL,但不能用作URL

时间:2019-02-05 09:14:10

标签: php curl twilio-api

这是两个GET请求。第一个使用CURL中的php可以工作,但是第二个由HTML form生成的响应会收到来自响应服务器的错误。

第一个(有效的)是使用CURL的GET请求

1。

curl 'https://api.authy.com/protected/json/phones/verification/start' \
-d api_key=my_key\
-d via=sms \
-d phone_number=my_number\
-d country_code=my_code

第二个(无效)是一个GET请求URL,例如一个从html格式<form method='get'>生成的请求URL

2。

https://api.authy.com/protected/json/phones/verification/start?api_key=my_key&via=sms&phone_number=my_number&country_code=my_code

使用第二个响应服务器时,来自响应服务器的错误消息是:

{"message":"Requested URL was not found. Please check http://docs.authy.com/ to see the valid URLs","success":false,"errors":{"message":"Requested URL was not found. Please check http://docs.authy.com/ to see the valid URLs"},"error_code":"60000"}

问题

第二个GET请求与CURL GET请求之间有什么区别?他们在我看来就像他们一样。

1 个答案:

答案 0 :(得分:6)

根据https://www.twilio.com/docs/verify/api/verification的文档,您应该使用POST请求来使用该API,这就是cURL的-d选项的作用。

在第二个呼叫中,您发送一个GET请求,并且根据文档和错误消息,该请求不成功

相关问题