首頁  >  問答  >  主體

【php】php有沒有請求 restful 介面的類別庫?

之前開發手寫了curl的方法,支援get和post請求

現在要用 put 和 delete 方法,我想找一個專門負責請求的類別庫,不知有沒有?最好能 composer 安裝,謝謝

ringa_leeringa_lee2668 天前825

全部回覆(3)我來回復

  • 我想大声告诉你

    我想大声告诉你2017-06-10 09:49:29

    https://packagist.org/package... 這個

    回覆
    0
  • 我想大声告诉你

    我想大声告诉你2017-06-10 09:49:29

    guzzle,requests比較常用

    回覆
    0
  • typecho

    typecho2017-06-10 09:49:29

    A proper REST client for php 一直在用這個,還不錯。

    <?php
    
    $pest = new Pest('http://example.com');
    
    $thing = $pest->get('/things');
    
    $thing = $pest->post('/things', 
        array(
            'name' => "Foo",
            'colour' => "Red"
        )
    );
    
    $thing = $pest->put('/things/15',
        array(
            'colour' => "Blue"
        )
    );
    
    $pest->delete('/things/15');
    
    ?>

    回覆
    0
  • 取消回覆