twilio / authy-php

A PHP client for Authy
245 stars 87 forks source link

Support errors and status codes as stated on Twilio API #59

Closed nmargaritis closed 2 years ago

nmargaritis commented 6 years ago

Currently due to the implementation of the AuthyResponse class (protected internal variables), there is no way to access the response body or status code directly without rewriting (extending classes) of the library yourself.

This creates an issue with error handling. As stated here https://www.twilio.com/docs/verify/return-and-error-codes there are multiple status codes as well as custom error codes (which are part of the response's body).

It would be beneficial to add a body() and a statusCode() function (or similar) to the said class.

public function body()
{
        return $this->body;
}

public function statusCode()
{
        return $this->raw_response->getStatusCode();
}

It appears that there is a bodyvar method. However, the status code is not available and bodyvar is restricting the usage of custom exception handling based on the body contents, you need to retrieve every variable independently.

nmargaritis commented 6 years ago

Also bodyvar makes debugging difficult. You first need to know everything (all body content names) in order to retrieve them, one by one. If you explore the API via the API itself while you integrate it then issues might arise. Apart from that, in the Twilio API documentation it is not clearly stated what is the response structure for errors. For example is it errorCode or error_code or something else in the response body? https://www.twilio.com/docs/verify/return-and-error-codes

robinske commented 2 years ago

This library is no longer actively maintained. The Authy API has been replaced with the Twilio Verify API. Twilio will support the Authy API through November 1, 2022 for SMS/Voice. After this date, we’ll start to deprecate the service for SMS/Voice. Any requests sent to the API after May 1, 2023, will automatically receive an error. Push and TOTP will continue to be supported through July 2023.

Learn more about migrating from Authy to Verify.

Please visit the Twilio Docs for:

Please direct any questions to Twilio Support. Thank you!