geronimo794/php-simple-curl-class
Composer 安装命令:
composer require geronimo794/php-simple-curl-class
包简介
Simple curl class helper
README 文档
README
Version 1.0.0
Php class to make simple curl request. Can use as code igniter library or as php class.
Geting started
- As PHP Class
Step 1 : Download the curl class here here
Step 2 : Include or require the curl class in your php file
require('Curl.php');
Step 3 : Create object from curl class
$my_curl = new Curl();
Step 4 : Set the url of curl request
$my_curl->setUrl('https://api.instagram.com/v1/media/shortcode/BLLZnwjAeEm');
Step 5 : Set the GET/POST parameter to send via curl
$my_curl->setGetData('access_token', 'abxcsdfsdfasdasd'); $my_curl->setPostData('private_key', 'fgxftfsadfsadsad');
OR
$var_to_send = array( 'access_token' => 'abxcsdfsdfasdasd', 'private_key' => 'fgxftfsadfsadsad' ); $my_curl->setGetData($var_to_send); $my_curl->setPostData($var_to_send);
Step 6 : Set the user_agent of curl
$my_curl->setUserAgent('Maybe mozilla');
Step 7 : Get the curl response
$curl_respon = $my_curl->getResponse();
- As Code Igniter Library
Step 1 : Download the curl class here here
Step 2 : Put the class file to Code Igniter library

Step 3 : Load curl library in your controller
$this->load->library('curl');
Step 4 : Set the url of curl request
$this->curl->setUrl('https://api.instagram.com/v1/media/shortcode/BLLZnwjAeEm');
Step 5 : Set the GET/POST parameter to send via curl
$this->curl->setGetData('access_token', 'abxcsdfsdfasdasd'); $this->curl->setPostData('private_key', 'fgxftfsadfsadsad');
OR
$var_to_send = array( 'access_token' => 'abxcsdfsdfasdasd', 'private_key' => 'fgxftfsadfsadsad' ); $this->curl->setGetData($var_to_send); $this->curl->setPostData($var_to_send);
Step 6 : Set the user_agent of curl
$this->curl->setUserAgent('Maybe mozilla');
Step 7 : Get the curl response
$curl_respon = $this->curl->getResponse();
Avaible methods
- clear() : Clear all the given setting to curl object
- setUrl( $url ) : Set the url of curl request
- setUserAgent( $userAgent ) : Set useragent
- setPostData( $name, $value ) : Set the post data
- setPostData( array( $name => $value ) ) : Set the post data
- setGetData( $name, $value ) : Set the get data
- setGetData( array( $name => $value ) ) : Set the get data
- getResponse() : Get response from curl
- setOption( array( CURL_OPT => CURL_OPT_VAL ) ) (06-12-2016) : Set the additional value for curl options with array
- setOption( CURL_OPT, CURL_OPT_VAL ) (06-12-2016) : Set the additional value for curl options with single option and value New method Version 1.2.0
- setHeaderData( array( $name => $value ) ) : Set header data for the curl request with array
- setHeaderData( $name, $value ) : Set header data for the curl request with name and value of header data
- setBody( $requestBody ) : Set the body of the curl request, it's usefull when you want to send json data through request body
- setRequestMethod( $requestMethod ) : Set curl request method it can be GET, POST, PUT, DELETE
- getInstance() : Get the current instance of the curl for the multiple curl request
- getResponseMultiInit( $curlInstance = [] ) : Its use for curl multiple instance initiation request, so you can multiple curl request at once
Changelogs
Version 1.0.0
- setData, setUrl, setUserAgent, clear, getResponse.
Version 1.0.1 (06-12-2012)
- Add new method setOption.
Version 1.2.0 (24-03-2018)
- Add new method setHeaderData, setBody, setRequestMethod, getInstance, and getResponseMultiInit.
geronimo794/php-simple-curl-class 适用场景与选型建议
geronimo794/php-simple-curl-class 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 505 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 12 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 geronimo794/php-simple-curl-class 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 geronimo794/php-simple-curl-class 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 505
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-10

