You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-10Lines changed: 61 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ This version requires [PHP](https://php.net) 7.1-7.4.
28
28
To get the latest version, simply require the project using [Composer](https://getcomposer.org). You will need to install any package that "provides" `php-http/client-implementation`. Pure PHP users will want something like:
@@ -42,24 +42,75 @@ We are decoupled from any HTTP messaging client with help by [HTTPlug](http://ht
42
42
43
43
## Usage
44
44
45
-
The main point of entry is the `Bitbucket\Client` class. Simply create a new instance of that, and you're good to go!
45
+
The main point of entry is the `Bitbucket\Client` class. Simply create a new instance of that, authenticate, and you're good to go! As of time of writing (Saturday 29th June 2019), every endpoint (excluding issue export and import, and various deprecated endpoints) available on the Bitbucket API 2.0 is also available through this PHP client. We'd recommend looking through the [Bitbucket documentation](https://developer.atlassian.com/bitbucket/api/2/reference/), and also the [source code](https://github.com/BitbucketAPI/Client/tree/2.1/src) to get a full picture of what is available to use.
46
46
47
-
Practically, you will also want to set authentication details before calling any of the endpoint, however, this is not required to call endpoints for which authentication is not needed. We support logging in with an OAuth2 token, or with a username and password.
47
+
### Authentication
48
+
49
+
There are two ways to authenticate our client:
50
+
51
+
#### OAuth 2 Token
52
+
53
+
The most common way to authenticate is using an OAuth 2 token. You will need to generate this by some means outside of the library, and then provide it as below:
54
+
55
+
```php
56
+
$client = new Bitbucket\Client();
57
+
58
+
$client->authenticate(
59
+
Bitbucket\Client::AUTH_OAUTH_TOKEN,
60
+
'your-token-here'
61
+
);
62
+
```
63
+
64
+
#### HTTP Password
65
+
66
+
It is possible to login using a username and password combination. This method is not recommended for production use, however you find it useful never the less:
48
67
49
68
```php
50
-
<?php
69
+
$client = new Bitbucket\Client();
70
+
71
+
$client->authenticate(
72
+
Bitbucket\Client::AUTH_HTTP_PASSWORD,
73
+
'your-username-here',
74
+
'your-password-here'
75
+
);
76
+
```
77
+
78
+
### Examples
51
79
52
-
use Bitbucket\Client;
80
+
In the following examples, `$client` will be an authenticated client, as above.
It is possible to show basic information about the currently logged in user:
58
85
59
-
var_dump($c->currentUser()->show());
86
+
```php
87
+
$currentUser = $client->currentUser()->show();
88
+
```
89
+
90
+
#### Example 2
91
+
92
+
It is possible to grab a repository as follows:
93
+
94
+
```php
95
+
$repository = $client->repositories()
96
+
->users('atlassian')
97
+
->show('stash-example-plugin');
60
98
```
61
99
62
-
As of time of writing (Saturday 29th June 2019), every endpoint (excluding issue export and import) available on the Bitbucket API 2.0 is also available through this PHP client. I'd recommend looking through the [Bitbucket documentation](https://developer.atlassian.com/bitbucket/api/2/reference/), and also the [generated documentation](https://bitbucketapi.github.io/Client/).
100
+
#### Example 3
101
+
102
+
We support automatic pagination without you having to lift a finger. The following example gets all branches of a repository:
0 commit comments