Coder Social home page Coder Social logo

curl-lib's Introduction

Simple cURL Library

Simple wrapper for cURL using PHP.

NOTE: Supported composer package from v2.0.0, If you need native version you can check v1.0.0

Installation

composer require andhikayuana/curl-lib

Usage

Create instance

require 'vendor/autoload.php';

$curl = new \Yuana\Curl();

HTTP GET method

$res = $curl->get('http://api.halo.com/users');

// using query
// http://api.halo.com/users?users_id=2
$res = $curl->get('http://api.halo.com/users', [
    'users_id' => 2
]);

HTTP POST method

$res = $curl->post('http://api.halo.com/login', [
    'username' => 'yuana',
    'password' => 'yourpassword'
]);

HTTP PUT method

$res = $curl->put('http://api.halo.com/users', [
    'users_id' => 3,
    'users_name' => 'Yuana Andhika',
    'users_dept' => 'Android Developer'
]);

HTTP DELETE method

$res = $curl->delete('http://api.halo.com/users', [
    'users_id' => 3
]);

Uploading file

$res = $curl->upload('http://api.domain.com/upload', [
    'fieldA' => '/path/to/file/fileA.jpg',
    'fieldB' => '/path/to/file/fileB.jpg',
]);

Configuration

//override timeout [default 30]
$curl->timeout = 25;

//override redirection [default true]
$curl->isRedirect = false;

//override user agent [default from http user agent]
$curl->userAgent = 'Android App 1.1';

//override headers
$curl->headers = [
    'Authorization' => 'Bearer yourtokenhere'
];

Contributing

Feel free to check CONTRIBUTING.md file

Todos

  • Proxy
  • Composer Package

Donation

ko-fi

curl-lib's People

Contributors

andhikayuana avatar fannyhasbi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

curl-lib's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.