EazyHttp, easy, simple and fast HTTP requests for PHP, JavaScript, Python
version 1.2.0
supports
PHP (in any desired order)
curl(if available)file_get_contents(if available)sockets/fsockopen(if available)
JavaScript/Browser (in any desired order)
fetch(if available)XMLHttpRequest(if available)iframe(if available)
JavaScript/Node (in any desired order)
http/https(if available)fetch(if available)
JavaScript/XPCOM
XMLHttpRequest(if available)
Python (in any desired order)
urllibsocket
example
PHP
$http = newEazyHttp();
// HTTP GET request$response = $http->option(
'timeout', 30// secs, default
)->option(
'follow_redirects', 3// default
)->option(
'methods', ['curl', 'file', 'socket'] // default order
)->get(
'https://example.com/',
['foo' => 'bar'], // custom URL params
['User-Agent' => 'EazyHttp'], // custom Headers
['a_cookie' => 'some cookie value'] // custom Cookies
);
// HTTP POST request$response = $http->option(
'timeout', 30// secs, default
)->option(
'follow_redirects', 3// default
)->option(
'methods', ['curl', 'file', 'socket'] // default order
)->post(
'https://example.com/',
['foo' => 'bar'], // custom post data
['User-Agent' => 'EazyHttp'], // custom Headers
['a_cookie' => 'some cookie value'] // custom Cookies
);
echojson_encode($response); // stdClass: {status}, {content}, {headers}, {cookies}JavaScript (browser and node)
consthttp=newEazyHttp();// HTTP GET requesthttp.option('timeout',30// secs, default).option('follow_redirects',3// default).option('methods',['http','fetch','xhr','iframe']// default order).option('return_type','string'// default, 'string' or 'buffer').get('https://example.com/',{'foo' : 'bar'},// custom URL params{'User-Agent' : 'EazyHttp'},// custom Headers{'a_cookie' : 'some cookie value'}// custom Cookies).then((response)=>console.log(JSON.stringify(response))// Object: {status}, {content}, {headers}, {cookies});// HTTP POST requesthttp.option('timeout',30// secs, default).option('follow_redirects',3// default).option('methods',['http','fetch','xhr','iframe']// default order).option('return_type','string'// default, 'string' or 'buffer').post('https://example.com/',{'foo' : 'bar'},// custom post data{'User-Agent' : 'EazyHttp'},// custom Headers{'a_cookie' : 'some cookie value'}// custom Cookies).then((response)=>console.log(JSON.stringify(response))// Object: {status}, {content}, {headers}, {cookies});Python
http=EazyHttp()
# HTTP GET requestresponse=http.option(
'timeout', 30# secs, default
).option(
'follow_redirects', 3# default
).option(
'methods', ['urllib', 'socket'] # default order
).get(
'https://example.com/',
{'foo' : 'bar'}, # custom URL params
{'User-Agent' : 'EazyHttp'}, # custom Headers
{'a_cookie' : 'some cookie value'} # custom Cookies
)
# HTTP POST requestresponse=http.option(
'timeout', 30# secs, default
).option(
'follow_redirects', 3# default
).option(
'methods', ['urllib', 'socket'] # default order
).post(
'https://example.com/',
{'foo' : 'bar'}, # custom post data
{'User-Agent' : 'EazyHttp'}, # custom Headers
{'a_cookie' : 'some cookie value'} # custom Cookies
)
importjsonprint(json.dumps(response)) # dict: {status}, {content}, {headers}, {cookies}see also:
- ModelView a simple, fast, powerful and flexible MVVM framework for JavaScript
- tico a mini, super-simple MVC framework for PHP
- LoginManager a simple, barebones agnostic login manager for PHP, JavaScript, Python
- SimpleCaptcha a simple, image-based, mathematical captcha with increasing levels of difficulty for PHP, JavaScript, Python
- Dromeo a flexible, and powerful agnostic router for PHP, JavaScript, Python
- PublishSubscribe a simple and flexible publish-subscribe pattern implementation for PHP, JavaScript, Python
- Localizer a simple and versatile localization class (l10n) for PHP, JavaScript, Python
- Importer simple class & dependency manager and loader for PHP, JavaScript, Python
- EazyHttp easy, simple and fast HTTP requests for PHP, JavaScript, Python
- RT a versatile real-time communication client for JavaScript supporting Polling / BOSH / WebSockets / WebRTC
- AjaxListener.js a listener for any AJAX event for JavaScript, even by other scripts
- Contemplate a fast and versatile isomorphic template engine for PHP, JavaScript, Python
- HtmlWidget html widgets, made as simple as possible, both client and server, both desktop and mobile, can be used as (template) plugins and/or standalone for PHP, JavaScript, Python (can be used as plugins for Contemplate)
- Paginator simple and flexible pagination controls generator for PHP, JavaScript, Python
- Formal a simple and versatile (Form) Data validation framework based on Rules for PHP, JavaScript, Python
- Dialect a cross-vendor & cross-platform SQL Query Builder, based on GrammarTemplate, for PHP, JavaScript, Python
- DialectORM an Object-Relational-Mapper (ORM) and Object-Document-Mapper (ODM), based on Dialect, for PHP, JavaScript, Python
- Unicache a simple and flexible agnostic caching framework, supporting various platforms, for PHP, JavaScript, Python
- Xpresion a simple and flexible eXpression parser engine (with custom functions and variables support), based on GrammarTemplate, for PHP, JavaScript, Python
- Regex Analyzer/Composer Regular Expression Analyzer and Composer for PHP, JavaScript, Python
