@@ -3,7 +3,7 @@ Nexmo Client Library for PHP
33[ ![ Build Status] ( https://api.travis-ci.org/Nexmo/nexmo-php.svg?branch=master )] ( https://travis-ci.org/Nexmo/nexmo-php )
44
55This is the PHP client library for use Nexmo's API. To use this, you'll need a Nexmo account. Sign up [ for free at
6- nexmo.com] [ signup ] .
6+ nexmo.com] [ signup ] . This is currently a beta release, see [ contributing ] ( #contributing ) for more information.
77
88 * [ Installation] ( #installation )
99 * [ Usage] ( #usage )
@@ -55,7 +55,7 @@ The API response data can be accessed as array properties of the message.
5555
5656 echo "Sent message to " . $message['to'] . ". Balance is now " . $message['remaining-balance'] . PHP_EOL;
5757
58- The message objects is a more expressive way to create and send messages. Each message type can be constructed with the
58+ ** A message object ** is a more expressive way to create and send messages. Each message type can be constructed with the
5959required parameters, and a fluent interface provides access to optional parameters.
6060
6161 $text = new \Nexmo\Message\Text(NEXMO_TO, NEXMO_FROM, 'Test message using PHP client library');
@@ -85,6 +85,97 @@ specific message data can be accessed using array notation, passing an index to
8585
8686The [ send example] [ send_example ] also has full working examples.
8787
88+ ### Receiving A Message
89+
90+ Inbound messages are [ sent to your application as a webhook] [ doc_inbound ] , and the client library provides a way to
91+ create an inbound message object from a webhook:
92+
93+ $inbound = \Nexmo\Message\InboundMessage::createFromGlobals();
94+ if($inbound->isValid()){
95+ error_log($inbound->getBody());
96+ } else {
97+ error_log('invalid message');
98+ }
99+
100+ You can also access the webhook data as an arry:
101+
102+ $inbound = \Nexmo\Message\InboundMessage::createFromGlobals();
103+ error_log($inbound['to']);
104+
105+ ### Fetching A Message
106+
107+ You can retrieve a message log from the API using the ID of the message:
108+
109+ $message = $client->message()->search('02000000DA7C52E7');
110+ echo "The body of the message was: " . $message->getBody();
111+
112+ If the message was sent to a Nexmo virtual number, the object will be an instance of ` Nexmo\Message\InboundMessage ` , if
113+ the message was sent from your account, it will be an instance of ` Nexmo\Message\Message ` . You can also pass a message
114+ object to the client:
115+
116+ $message = new \Nexmo\Message\InboundMessage('02000000DA7C52E7');
117+ $client->message()->search($message);
118+ echo "The body of the message was: " . $message->getBody();
119+
120+ ### Starting a Verification
121+
122+ Nexmo's [ Verify API] [ doc_verify ] makes it easy to prove that a user has provided their own phone number during signup,
123+ or implement second factor authentication during signin.
124+
125+ You can start a verification process using a simple array:
126+
127+ $verification = $client->verify()->start([
128+ 'number' => '14845551212',
129+ 'brand' => 'My App'
130+ ]);
131+ echo "Started verification with an id of: " . $verification->getRequestId();
132+
133+ Or you can pass the client a verification object:
134+
135+ $verification = new \Nexmo\Verify\Verification('14845551212', 'My App');
136+ $client->verify()->start($verification);
137+ echo "Started verification with an id of: " . $verification->getRequestId();
138+
139+ ### Controlling a Verification
140+
141+ To cancel an in-progress verification, or to trigger the next attempt to send the confirmation code, you can pass
142+ either an exsisting verification object to the client library, or simply use a request ID:
143+
144+ $client->verify()->trigger('00e6c3377e5348cdaf567e1417c707a5');
145+
146+ $verification = new \Nexmo\Verify\Verification('00e6c3377e5348cdaf567e1417c707a5');
147+ $client->verify()->cancel($verification);
148+
149+ ### Checking A Verification
150+
151+ In the same way, checking a verification requires the code the user provided, and an exiting verification object:
152+
153+ $verification = new \Nexmo\Verify\Verification('00e6c3377e5348cdaf567e1417c707a5');
154+ $client->verify()->check($verification, '1234');
155+
156+ Or a request ID:
157+
158+ $client->verify()->check('00e6c3377e5348cdaf567e1417c707a5', '1234');
159+
160+ ### Searching For A Verification
161+
162+ You can check the status of a verification, or access the results of past verifications using either an exsisting
163+ verification object, or a request ID. The verification object will then provide a rich interface:
164+
165+ $verification = new \Nexmo\Verify\Verification('00e6c3377e5348cdaf567e1417c707a5');
166+ $client->verify()->search($verification);
167+
168+ echo "Codes checked for verification: " . $verification->getRequestId() . PHP_EOL;
169+ foreach($verification->getChecks() as $check){
170+ echo $check->getDate()->format('d-m-y') . ' ' . $check->getStatus() . PHP_EOL;
171+ }
172+
173+ You can also access the raw API response here using array access:
174+
175+ $verification = new \Nexmo\Verify\Verification('00e6c3377e5348cdaf567e1417c707a5');
176+ $client->verify()->search($verification);
177+ echo "Verification cost was: " . $verification['price'] . PHP_EOL;
178+
88179API Coverage
89180------------
90181
@@ -111,9 +202,9 @@ API Coverage
111202* Messaging
112203 * [X] Send
113204 * [ ] Delivery Receipt
114- * [ ] Inbound Messages
115- * [ ] Search
116- * [ ] Message
205+ * [X ] Inbound Messages
206+ * [X ] Search
207+ * [X ] Message
117208 * [ ] Messages
118209 * [ ] Rejections
119210 * US Short Codes
@@ -145,6 +236,8 @@ This library is released under the [MIT License][license]
145236
146237[ signup ] : https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=[LANGUAGE]-client-library
147238[ doc_sms ] : https://docs.nexmo.com/api-ref/sms-api?utm_source=DEV_REL&utm_medium=github&utm_campaign=[LANGUAGE]-client-library
239+ [ doc_inbound ] : https://docs.nexmo.com/messaging/sms-api/api-reference#inbound?utm_source=DEV_REL&utm_medium=github&utm_campaign=[LANGUAGE]-client-library
240+ [ doc_verify ] : https://docs.nexmo.com/verify/api-reference?utm_source=DEV_REL&utm_medium=github&utm_campaign=[LANGUAGE]-client-library
148241[ license ] : LICENSE.txt
149242[ send_example ] : examples/send.php
150243[ spec ] : https://github.com/Nexmo/client-library-specification
0 commit comments