[英]How to call API using POST or PUT
我需要通過帶有自定義標頭和自定義HTTP動詞的HTTP請求來調用API
PUT: http://www.example.com/system/get_user_categories/format/json/user_id/**10**
我想我需要使用:
request::create
但是我不知道如何。
對於此任務,您可以使用“ Guzzle” PHP-HTTP-Client。
發送請求GET,POST,PUT,DELETE ...
http://guzzle.readthedocs.org/en/latest/http-messages.html#requests
http://guzzle.readthedocs.org/en/latest/clients.html#sending-requests
有關自定義標題,請參見:
http://guzzle.readthedocs.org/en/latest/http-messages.html#headers
Guzzle功能強大且易於使用,並且可以嘗試許多“復制粘貼”示例:)
Symfony2 Guzzle作曲家軟件包:
Laravel的request對象只是擴展了Symfony的HTTP請求類(並添加了一些Laravel特定的方法),因此,您可以使用Symfony\\Component\\HttpFoundation\\Request
都可以使用Laravel的request類進行處理。
您是對的,可以使用Request::create()
。 請參閱Symfony文檔中的此部分: http : //symfony.com/doc/current/components/http_foundation/introduction.html#simulating-a-request
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.