guzzle不知不覺升級到六,升級以後和原來3.*的時候用法不一樣了,看文檔也迷糊,找了半天才從文檔找到用法:
POST
<code><span>$response</span> = <span>$client</span>->request(<span>'POST'</span>, <span>'http://httpbin.org/post'</span>, [ <span>'form_params'</span> => [ <span>'field_name'</span> => <span>'abc'</span>, <span>'other_field'</span> => <span>'123'</span>, <span>'nested_field'</span> => [ <span>'nested'</span> => <span>'hello'</span> ] ] ]); <span>$result</span> = <span>$response</span>->getBody();</code>
GET
<code><span>$client</span><span>=</span><span>new</span> Client(); <span>$res</span><span>=</span><span>$client</span><span>-></span>request(<span>'GET'</span>, <span>$url</span><span>.</span><span>"?param1=1¶m2=9"</span>); <span>$result</span><span>=</span><span>$res</span><span>-></span>getBody();</code>
講道理,還是挺方便的。
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });以上就介紹了php 用guzzule 6 發送HTTP請求,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。