Skip to content

Commit 283df64

Browse files
author
Martin Steel
committed
Add syntax highlighting to readme
1 parent 066f0a8 commit 283df64

1 file changed

Lines changed: 59 additions & 42 deletions

File tree

README.md

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ This wrapper lets you interact with Clockwork without the hassle of having to cr
1414

1515
Require the Clockwork library:
1616

17-
require 'class-Clockwork.php';
17+
```php
18+
require 'class-Clockwork.php';
19+
```
1820

1921
### Sending a message
2022

@@ -28,13 +30,14 @@ $result = $clockwork->send( $message );
2830

2931
We recommend you use batch sizes of 500 messages or fewer. By limiting the batch size it prevents any timeouts when sending.
3032

31-
$clockwork = new Clockwork( $API_KEY );
32-
$messages = array(
33-
array( 'to' => '441234567891', 'message' => 'This is a test!' ),
34-
array( 'to' => '441234567892', 'message' => 'This is a test 2!' )
35-
);
36-
$results = $clockwork->send( $messages );
37-
33+
```php
34+
$clockwork = new Clockwork( $API_KEY );
35+
$messages = array(
36+
array( 'to' => '441234567891', 'message' => 'This is a test!' ),
37+
array( 'to' => '441234567892', 'message' => 'This is a test 2!' )
38+
);
39+
$results = $clockwork->send( $messages );
40+
```
3841

3942
### Handling the response
4043

@@ -105,9 +108,11 @@ For example, if you send to invalid phone number "abc":
105108

106109
Check your available SMS balance:
107110

108-
$clockwork = new Clockwork( $API_KEY );
109-
$clockwork->checkBalance();
110-
111+
```php
112+
$clockwork = new Clockwork( $API_KEY );
113+
$clockwork->checkBalance();
114+
```
115+
111116
This will return:
112117

113118
Array
@@ -121,24 +126,28 @@ This will return:
121126

122127
The Clockwork wrapper will throw a `ClockworkException` if the entire call failed.
123128

124-
try
125-
{
126-
$clockwork = new Clockwork( 'invalid_key' );
127-
$message = array( 'to' => 'abc', 'message' => 'This is a test!' );
128-
$result = $clockwork->send( $message );
129-
}
130-
catch( ClockworkException $e )
131-
{
132-
print $e->getMessage();
133-
// Invalid API Key
134-
}
129+
```php
130+
try
131+
{
132+
$clockwork = new Clockwork( 'invalid_key' );
133+
$message = array( 'to' => 'abc', 'message' => 'This is a test!' );
134+
$result = $clockwork->send( $message );
135+
}
136+
catch( ClockworkException $e )
137+
{
138+
print $e->getMessage();
139+
// Invalid API Key
140+
}
141+
```
135142

136143
### Advanced Usage
137144

138145
This class has a few additional features that some users may find useful, if these are not set your account defaults will be used.
139146

140147
### Optional Parameters
141148

149+
See the [Clockwork Documentation](http://www.clockworksms.com/doc/clever-stuff/xml-interface/send-sms/) for full details on these options.
150+
142151
* $from [string]
143152

144153
The from address displayed on a phone when they receive a message
@@ -171,45 +180,53 @@ Options set on the API object will apply to all SMS messages unless specifically
171180

172181
In this example both messages will be sent from Clockwork:
173182

174-
$options = array( 'from' => 'Clockwork' );
175-
$clockwork = new Clockwork( $API_KEY, $options );
176-
$messages = array(
177-
array( 'to' => '441234567891', 'message' => 'This is a test!' ),
178-
array( 'to' => '441234567892', 'message' => 'This is a test 2!' )
179-
);
180-
$results = $clockwork->send( $messages );
183+
```php
184+
$options = array( 'from' => 'Clockwork' );
185+
$clockwork = new Clockwork( $API_KEY, $options );
186+
$messages = array(
187+
array( 'to' => '441234567891', 'message' => 'This is a test!' ),
188+
array( 'to' => '441234567892', 'message' => 'This is a test 2!' )
189+
);
190+
$results = $clockwork->send( $messages );
191+
```
181192

182193
#### Per-message Options
183194

184195
Set option values individually on each message.
185196

186197
In this example, one message will be from Clockwork and the other from 84433:
187198

188-
$clockwork = new Clockwork( $API_KEY, $options );
189-
$messages = array(
190-
array( 'to' => '441234567891', 'message' => 'This is a test!', 'from' => 'Clockwork' ),
191-
array( 'to' => '441234567892', 'message' => 'This is a test 2!', 'from' => '84433' )
192-
);
193-
$results = $clockwork->send( $messages );
199+
```php
200+
$clockwork = new Clockwork( $API_KEY, $options );
201+
$messages = array(
202+
array( 'to' => '441234567891', 'message' => 'This is a test!', 'from' => 'Clockwork' ),
203+
array( 'to' => '441234567892', 'message' => 'This is a test 2!', 'from' => '84433' )
204+
);
205+
$results = $clockwork->send( $messages );
206+
```
194207

195208
### SSL Errors
196209

197210
Due to the huge variety of PHP setups out there a small proportion of users may get PHP errors when making API calls due to their SSL configuration.
198211

199212
The errors will generally look something like this:
200213

201-
Fatal error:
202-
Uncaught exception 'Exception' with message 'HTTP Error calling Clockwork API
203-
HTTP Status: 0
204-
cURL Erorr: SSL certificate problem, verify that the CA cert is OK.
205-
Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed'
214+
```
215+
Fatal error:
216+
Uncaught exception 'Exception' with message 'HTTP Error calling Clockwork API
217+
HTTP Status: 0
218+
cURL Erorr: SSL certificate problem, verify that the CA cert is OK.
219+
Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed'
220+
```
206221

207222
If you're seeing this error there are two fixes available, the first is easy, simply disable SSL on Clockwork calls. Alternatively you can setup your PHP install with the correct root certificates.
208223

209224
#### Disable SSL on Clockwork calls
210225

211-
$options = array( 'ssl' => false );
212-
$clockwork = new Clockwork( $API_KEY, $options );
226+
```php
227+
$options = array( 'ssl' => false );
228+
$clockwork = new Clockwork( $API_KEY, $options );
229+
```
213230

214231
#### Setup SSL root certificates on your server
215232

0 commit comments

Comments
 (0)