2014-09-03 136 views

回答

3

取決於請求需要多麼複雜的是。您可以使用curl甚至file_get_contents來獲取簡單的get請求,也可以像Guzzle一樣安裝一個包來處理更復雜的事情。

https://github.com/guzzle/guzzle

1

隨着 '正常' 的PHP,你可以用捲曲的HTTP協議(POST/GET)工作。如果你正在使用Laravel,你可以建立自己的捲曲的方法,也可以使用與作曲家/ Laravel兼容的第三方curl庫:

https://packagist.org/packages/unikent/curl 
0

您可以使用狂飲 在composer.json添加的依賴包文件

{ 
    "require": { 
     "guzzlehttp/guzzle": "~4.0" //you can change the version 
    } 
} 

化妝作曲家安裝或更新

要創建與狂飲的第一個請求,一個代碼片段如下面簡單的將工作:

use GuzzleHttp\Client; 
use GuzzleHttp\Message\Request; 
use GuzzleHttp\Message\Response; 

$client = new Client(); 
$response = $client->get("https://api.github.com/"); 
retrun $response; 
相關問題