Browse code

Added README.md appinfo/info.xml appinfo/signature.json lib/Controller/AuthorApiController.php and the providers directory

DoubleBastionAdmin authored on 20/08/2022 16:33:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,222 @@
1
+# Telnyx PHP SDK
2
+
3
+[![Build Status](https://github.com/team-telnyx/telnyx-php/workflows/Composer/badge.svg)](https://github.com/team-telnyx/telnyx-php/actions)
4
+[![Latest Stable Version](https://poser.pugx.org/telnyx/telnyx-php/v/stable.svg)](https://packagist.org/packages/telnyx/telnyx-php)
5
+[![Total Downloads](https://poser.pugx.org/telnyx/telnyx-php/downloads.svg)](https://packagist.org/packages/telnyx/telnyx-php)
6
+[![License](https://poser.pugx.org/telnyx/telnyx-php/license.svg)](https://packagist.org/packages/telnyx/telnyx-php)
7
+[![Code Coverage](https://coveralls.io/repos/github/team-telnyx/telnyx-php/badge.svg?branch=master&)](https://coveralls.io/github/team-telnyx/telnyx-php?branch=master&)
8
+[![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://joinslack.telnyx.com/)
9
+
10
+The Telnyx PHP library provides convenient access to the Telnyx API from
11
+applications written in PHP. It includes a pre-defined set of
12
+classes for API resources that initialize themselves dynamically from API
13
+responses.
14
+
15
+The library also provides other features. For example:
16
+
17
+* Easy configuration path for fast setup and use.
18
+* Helpers for pagination.
19
+* Built-in mechanisms for the serialization of parameters according to the
20
+  expectations of Telnyx's API.
21
+
22
+You can sign up for a Telnyx account at [telnyx.com](https://telnyx.com).
23
+
24
+
25
+## Requirements
26
+
27
+PHP 5.6.0 and later.
28
+
29
+## Composer
30
+
31
+You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
32
+
33
+```bash
34
+$ composer require telnyx/telnyx-php
35
+```
36
+
37
+## Manual Installation
38
+
39
+If you do not wish to use Composer, you can download the [latest release](https://github.com/team-telnyx/telnyx-php/releases). Then, to use the bindings, include the `init.php` file.
40
+
41
+```php
42
+require_once('/path/to/telnyx-php/init.php');
43
+```
44
+
45
+
46
+## Dependencies
47
+
48
+Some PHP extensions are required:
49
+
50
+- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
51
+- [`json`](https://secure.php.net/manual/en/book.json.php)
52
+- [`mbstring`](https://secure.php.net/manual/en/book.mbstring.php) (Multibyte String)
53
+
54
+Composer will handle these dependencies. If you install manually, you'll want to make sure that these extensions are available.
55
+
56
+
57
+## Getting Started
58
+
59
+Basic example:
60
+
61
+```php
62
+\Telnyx\Telnyx::setApiKey('YOUR_API_KEY_HERE');
63
+
64
+// Get a list of messaging profiles
65
+$result = \Telnyx\MessagingProfile::all();
66
+
67
+// Output list of messaging profiles
68
+print_r($result);
69
+```
70
+
71
+
72
+## Documentation
73
+
74
+Please see https://developers.telnyx.com/docs/api/v2/overview for up-to-date documentation.
75
+
76
+
77
+## Custom Request Timeouts
78
+
79
+To modify request timeouts (connect or total, in seconds) you'll need to tell the API client to use a CurlClient other than its default. You'll set the timeouts in that CurlClient.
80
+
81
+```php
82
+// set up your tweaked Curl client
83
+$curl = new \Telnyx\HttpClient\CurlClient();
84
+$curl->setTimeout(10); // default is Telnyx\HttpClient\CurlClient::DEFAULT_TIMEOUT
85
+$curl->setConnectTimeout(5); // default is Telnyx\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT
86
+
87
+echo $curl->getTimeout(); // 10
88
+echo $curl->getConnectTimeout(); // 5
89
+
90
+// tell Telnyx to use the tweaked client
91
+\Telnyx\ApiRequestor::setHttpClient($curl);
92
+
93
+// use the Telnyx API client as you normally would
94
+```
95
+
96
+
97
+## Custom cURL Options (proxies)
98
+
99
+Need to set a proxy for your requests? Pass in the requisite `CURLOPT_*` array to the CurlClient constructor, using the same syntax as `curl_stopt_array()`. This will set the default cURL options for each HTTP request made by the SDK, though many more common options (e.g. timeouts; see above on how to set those) will be overridden by the client even if set here.
100
+
101
+```php
102
+// set up your tweaked Curl client
103
+$curl = new \Telnyx\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
104
+// tell Telnyx to use the tweaked client
105
+\Telnyx\ApiRequestor::setHttpClient($curl);
106
+```
107
+
108
+Alternately, a callable can be passed to the CurlClient constructor that returns the above array based on request inputs. See `testDefaultOptions()` in `tests/CurlClientTest.php` for an example of this behavior. Note that the callable is called at the beginning of every API request, before the request is sent.
109
+
110
+
111
+## Configuring a Logger
112
+
113
+The library does minimal logging, but it can be configured
114
+with a [`PSR-3` compatible logger][psr3] so that messages
115
+end up there instead of `error_log`:
116
+
117
+```php
118
+\Telnyx\Telnyx::setLogger($logger);
119
+```
120
+
121
+
122
+## Accessing Response Data
123
+
124
+You can access the data from the last API response on any object via `getLastResponse()`.
125
+
126
+```php
127
+$order = \Telnyx\NumberOrder::create(['phone_number' => '+18665552368']);
128
+print_r($order->getLastResponse()->headers);
129
+```
130
+
131
+
132
+## SSL / TLS Compatibility issues
133
+
134
+Telnyx's API now requires that all connections use TLS 1.2. Some systems (most notably some older CentOS and RHEL versions) are capable of using TLS 1.2 but will use TLS 1.0 or 1.1 by default.
135
+
136
+The recommended course of action is to upgrade your cURL and OpenSSL packages so that TLS 1.2 is used by default, but if that is not possible, you might be able to solve the issue by setting the `CURLOPT_SSLVERSION` option to either `CURL_SSLVERSION_TLSv1` or `CURL_SSLVERSION_TLSv1_2`:
137
+
138
+```php
139
+$curl = new \Telnyx\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
140
+\Telnyx\ApiRequestor::setHttpClient($curl);
141
+```
142
+
143
+
144
+## Per-request Configuration
145
+
146
+For apps that need to use multiple keys during the lifetime of a process it's also possible to set a
147
+per-request key and/or account:
148
+
149
+```php
150
+\Telnyx\NumberOrder::all([], [
151
+    'api_key' => 'KEY0123...'
152
+]);
153
+
154
+\Telnyx\NumberOrder::retrieve("12ade33a-21c0-473b-b055-b3c836e1c292", [
155
+    'api_key' => 'KEY0123...'
156
+]);
157
+```
158
+
159
+
160
+## Automatic Retries
161
+
162
+The library can be configured to automatically retry requests that fail due to
163
+an intermittent network problem:
164
+
165
+```php
166
+\Telnyx\Telnyx::setMaxNetworkRetries(2);
167
+```
168
+
169
+
170
+## Development
171
+
172
+Unit tests rely on a mock server so all unit tests are ran through
173
+docker.  To run all unit tests execute:
174
+
175
+```
176
+docker-compose run --rm php composer test
177
+```
178
+
179
+Running unit tests with code coverage requires you build the docker
180
+container with XDEBUG=1
181
+
182
+```
183
+docker-compose build --build-arg XDEBUG=1
184
+```
185
+
186
+then run the unit tests as
187
+
188
+```
189
+docker-compose run --rm php composer test-coverage
190
+```
191
+
192
+
193
+## Plugin Developers
194
+
195
+Are you writing a plugin that integrates Telnyx and embeds our library? Then please use the `setAppInfo` function to identify your plugin. For example:
196
+
197
+```php
198
+\Telnyx\Telnyx::setAppInfo("MyCustomPlugin", "1.2.3", "https://customplugin.yoursite.com");
199
+```
200
+
201
+The method should be called once before any request is sent to the API. The second and third parameters are optional.
202
+
203
+
204
+## SSL / TLS Configuration Option
205
+
206
+See the "SSL / TLS compatibility issues" paragraph above for full context. If you want to
207
+ensure that your plugin can be used on all systems, you should add a configuration option
208
+to let your users choose between different values for
209
+`CURLOPT_SSLVERSION`: none (default), `CURL_SSLVERSION_TLSv1` and `CURL_SSLVERSION_TLSv1_2`.
210
+
211
+
212
+## Acknowledgments
213
+
214
+The contributors and maintainers of Telnyx PHP would like to extend their deep gratitude
215
+to the authors of [Stripe PHP][stripe-php], upon which this project is based. Thank you
216
+for developing such elegant, usable, and extensible code and for sharing it with the community.
217
+
218
+[stripe-php]: https://github.com/stripe/stripe-php
219
+[composer]: https://getcomposer.org/
220
+[curl]: http://curl.haxx.se/docs/caextract.html
221
+[psr3]: http://www.php-fig.org/psr/psr-3/
222
+