Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: various changes after site review #477

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Installation
------------

### Install with Composer
If you're using [Composer](https://github.com/composer/composer) to manage
If you're using [Composer](http://getcomposer.org/) to manage
dependencies, you can add Requests with it.

```sh
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ here are prose; you might also want to check out the [API documentation][].
[authentication]: authentication.md
[authentication-custom]: authentication-custom.md
[hooks]: hooks.md
[proxy]: proxy.md
[proxy]: proxy.md
2 changes: 1 addition & 1 deletion docs/authentication-custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ system documentation][hooks].

Previous: [Authenticating your request](authentication.md)

Next: [Requests through proxy](proxy.md)
Next: [Requests through proxy](proxy.md)
8 changes: 4 additions & 4 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A Basic authenticated call can be made like this:
$options = array(
'auth' => new Requests_Auth_Basic(array('user', 'password'))
);
Requests::get('http://httpbin.org/basic-auth/user/password', array(), $options);
Requests::get('https://httpbin.org/basic-auth/user/password', array(), $options);
```

As Basic authentication is usually what you want when you specify a username
Expand All @@ -20,18 +20,18 @@ and password, you can also just pass in an array as a shorthand:
$options = array(
'auth' => array('user', 'password')
);
Requests::get('http://httpbin.org/basic-auth/user/password', array(), $options);
Requests::get('https://httpbin.org/basic-auth/user/password', array(), $options);
```

Note that `POST`/`PUT` requests take a `$data` parameter, so you need to pass that
before `$options`:

```php
Requests::post('http://httpbin.org/basic-auth/user/password', array(), null, $options);
Requests::post('https://httpbin.org/basic-auth/user/password', array(), null, $options);
```

***

Previous: [Advanced usage](usage-advanced.md)

Next: [Custom authentification](authentication-custom.md)
Next: [Custom authentification](authentication-custom.md)
2 changes: 1 addition & 1 deletion docs/goals.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Goals

***

Next: [Why Requests Instead of X?](why-requests.md)
Next: [Why Requests Instead of X?](why-requests.md)
13 changes: 7 additions & 6 deletions docs/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Available Hooks

Parameters: `string &$response, array &$info`

`$info` contains the associated array as defined in [curl-getinfo-returnvalues](http://php.net/manual/en/function.curl-getinfo.php#refsect1-function.curl-getinfo-returnvalues)
`$info` contains the associated array as defined in the return value for [curl_getinfo()](http://php.net/manual/en/function.curl-getinfo.php#refsect1-function.curl-getinfo-returnvalues).

* **`fsockopen.before_request`**

Expand Down Expand Up @@ -77,7 +77,8 @@ Available Hooks

Parameters: `string &$response, array &$info`

`$info` contains the associated array as defined in [stream-get-meta-data-returnvalues](http://php.net/manual/en/function.stream-get-meta-data.php#refsect1-function.stream-get-meta-data-returnvalues)
`$info` contains the associated array as defined in the return value for [stream_get_meta_data()](http://php.net/manual/en/function.stream-get-meta-data.php#refsect1-function.stream-get-meta-data-returnvalues).



Registering Hooks
Expand All @@ -87,16 +88,16 @@ Authentication guide][authentication-custom] instead.

[authentication-custom]: authentication-custom.md

In order to register your own hooks, you need to instantiate `Requests_hooks`
and pass the object in via the 'hooks' option.
In order to register your own hooks, you need to instantiate `Requests_Hooks`
and pass the object in via the `'hooks'` option.

```php
$hooks = new Requests_Hooks();
$hooks->register('requests.after_request', 'mycallback');

$request = Requests::get('http://httpbin.org/get', array(), array('hooks' => $hooks));
$request = Requests::get('https://httpbin.org/get', array(), array('hooks' => $hooks));
```

***

Previous: [Requests through proxy](proxy.md)
Previous: [Requests through proxy](proxy.md)
6 changes: 3 additions & 3 deletions docs/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To make requests through an open proxy, specify the following options:
$options = array(
'proxy' => '127.0.0.1:3128'
);
Requests::get('http://httpbin.org/ip', array(), $options);
Requests::get('https://httpbin.org/ip', array(), $options);
```

If your proxy needs you to authenticate, the option will become an array like
Expand All @@ -19,11 +19,11 @@ in the following example:
$options = array(
'proxy' => array( '127.0.0.1:3128', 'my_username', 'my_password' )
);
Requests::get('http://httpbin.org/ip', array(), $options);
Requests::get('https://httpbin.org/ip', array(), $options);
```

***

Previous: [Custom authentification](authentication-custom.md)

Next: [Hooking system](hooks.md)
Next: [Hooking system](hooks.md)
2 changes: 1 addition & 1 deletion docs/usage-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ bugs in PHP for more information on Subject Alternate Name field.

Previous: [Making a request](usage.md)

Next: [Authenticating your request](authentication.md)
Next: [Authenticating your request](authentication.md)
28 changes: 6 additions & 22 deletions docs/usage.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
Usage
=====

Ready to go? Make sure you have Requests [installed][download] before attempting any of the
Ready to go? Make sure you have Requests [installed][download] and bootstrapped either the
Composer `autoload.php` file, the Requests autoload function or your autoloader, before attempting any of the
steps in this guide.

[download]: {{ '/download/' | prepend: site.baseurl }}


Loading Requests
----------------
Before we can load Requests up, we'll need to make sure it's loaded. This is a
straight-forward two-step:

```php
// First, include Requests
include('/path/to/library/Requests.php');

// Next, make sure Requests can load internal classes
Requests::register_autoloader();
```

If you'd like to bring along your own autoloader, you can forget about this
completely.


Make a GET Request
------------------
One of the most basic things you can do with HTTP is make a GET request.
Expand Down Expand Up @@ -63,7 +47,7 @@ Make a POST Request
Making a POST request is very similar to making a GET:

```php
$response = Requests::post('http://httpbin.org/post');
$response = Requests::post('https://httpbin.org/post');
```

You'll probably also want to pass in some data. You can pass in either a
Expand All @@ -74,7 +58,7 @@ internally) as the third parameter (after the URL and headers):

```php
$data = array('key1' => 'value1', 'key2' => 'value2');
$response = Requests::post('http://httpbin.org/post', array(), $data);
$response = Requests::post('https://httpbin.org/post', array(), $data);
var_dump($response->body);
```

Expand All @@ -96,7 +80,7 @@ This gives the output:
"Host": "httpbin.org",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
"url": "http://httpbin.org/post",
"url": "https://httpbin.org/post",
"args": {},
"data": ""
}"
Expand Down Expand Up @@ -161,4 +145,4 @@ If a header isn't set, this will give `null`. You can also check with

Previous: [Why should I use Requests instead of X?](why-requests.md)

Next: [Advanced usage](usage-advanced.md)
Next: [Advanced usage](usage-advanced.md)
8 changes: 4 additions & 4 deletions docs/why-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Why should I use Requests?

3. **Thoroughly tested**

Requests is [continuously integrated with Travis][travis] and test coverage
Requests is [continuously integrated with GH Actions][ghactions] and test coverage
is [constantly monitored with CodeCov][codecov] to give you confidence in
the library. We aim for test coverage **over 90%** at all times, and new
features require new tests to go along with them. This ensures that you can
Expand Down Expand Up @@ -61,7 +61,7 @@ Why should I use Requests?
[codecov]: https://app.codecov.io/gh/WordPress/Requests/branch/master
[hooking system]: hooks.md
[requests_ssl]: https://github.com/WordPress/Requests/blob/master/library/Requests/SSL.php
[travis]: https://travis-ci.org/WordPress/Requests
[ghactions]: https://github.com/WordPress/Requests/actions
[wpssl]: http://core.trac.wordpress.org/ticket/25007


Expand All @@ -81,7 +81,7 @@ instead of something else, in our opinion.
projects indicates that cURL is available on roughly 90% of hosts, but that
leaves 10% of hosts without it.

2. **cURL's interface sucks**
2. **cURL's interface is hard to work with**

cURL's interface was designed for PHP 4, and hence uses resources with
horrible functions such as `curl_setopt()`. Combined with that, it uses 229
Expand Down Expand Up @@ -176,4 +176,4 @@ instead of something else, in our opinion.

Previous: [Goals](goals.md)

Next: [Making a request](usage.md)
Next: [Making a request](usage.md)