php的 curl 类库,phpGrace 工具类库 - curl通信类

1c8553011679c82c79617d9547830ab7.png

功能介绍

curl通讯类,包含 get、post 方式。

部署说明将 curl.php 文件直接部署到 phpGrace/tools/ 文件夹下

使用演示 - GET<?php

class indexController extends grace{

public function index(){

$curl = new phpGrace\tools\curl();

$res  = $curl->get('http://api.hcoder.net');

//返回结果

echo $res;

}

}

使用演示 - POST<?php

class indexController extends grace{

public function index(){

$curl = new phpGrace\tools\curl();

//post 数据

$data = array('name' => 'grace', 'age' => 10);

$res  = $curl->post('http://api.hcoder.net', $data);

//curl 状态

p($curl->http_status);

//传输时间毫秒

echo $curl->speed;

//返回结果

echo $res;

}

}

获取 curl 资源对象curl 资源对象保存在 phpGrace curl对象的 curlHandle 属性,您可以获取它并继续完成其他功能:$curlo = $curl->curlHandle;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值