2

I am testing the Clickatell API to integrate SMS confirmations in my php based app, I've used their rest api to send the message to myself to test but the messages never arrive.

My Attempts

I used this https://www.clickatell.com/developers/api-docs/get-coverage-rest/ to check the coverage and this was the JSON response:

object(stdClass)[54]
  public 'data' => 
    object(stdClass)[57]
      public 'routable' => boolean true
      public 'destination' => string ' 21655609125' (length=12)
      public 'minimumCharge' => float 0.8

I've also made sure the message is actually sent by checking status; and this was the JSON response:

object(stdClass)[54]
  public 'data' => 
    object(stdClass)[57]
      public 'charge' => float 0.8
      public 'messageStatus' => string '004' (length=3)
      public 'description' => string 'Received by recipient' (length=21)
      public 'apiMessageId' => string 'b57f4a28dece65a134b56be2010c8a78' (length=32)
      public 'clientMessageId' => string '' (length=0)

I've then tried their own website for sent messages reports and that's what I see:

MESSAGE CONTENT Thanks for testing Clickatell's gateway coverage. You will be able to change the content of your message after your initial purchase of message credits.

Mobile Network Tunisia:Orange To 21655609125

Received by recipient (status 4)

But I never receive the message myself. What could be the issue?

Edit: here is the full class i use in my app currently

<?php

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

/**
 * MC_SMS class
 */
class MC_SMS {

    public  $rest_uri   = 'https://api.clickatell.com/rest';
    public  $method     = 'post';
    public  $args       = array();

    /**
     * Constructor
     */
    public function __construct( $action, $data = null ) {

        $this->data = $data;
        $this->init();

        switch( $action ) :

            // Send message
            case 'send' :

                $this->endpoint = '/message';
                $this->method = 'post';

                break;

            // Message status
            case 'status' :

                $this->endpoint = '/message/' . $data;
                $this->method = 'get';

                break;

            // Network coverage
            case 'coverage' :

                $this->endpoint = '/coverage/' . $data;
                $this->method = 'get';

                break;

            // Account balance
            case 'balance' :

                $this->endpoint = '/account/balance';
                $this->method = 'get';

                break;

        endswitch;

        $this->queried_uri = $this->rest_uri . $this->endpoint;
        $this->do_request();

        $this->response = ( isset( $this->response_body['body'] ) ) ? json_decode( $this->response_body['body'] ) : null;
    }

    /**
     * Init.
     */
    public function init() {
        $this->headers = array(
                'X-Version'     => 1,
                'Authorization' => 'Bearer ClHrbIEo_LwAlSVTSMemBIA5Gmvz8HNb5sio3N9GVDdAO_PPJPaZKzdi8Y8cDSmrs4A4',
                'Content-Type'  => 'application/json',
                'Accept'        => 'application/json'
        );

        $this->data = ( ! empty( $this->data ) && is_array( $this->data ) ) ? json_encode( $this->data ) : null;

        $this->args['headers'] = $this->headers;

        if ( $this->data ) {
            $this->args['body'] = $this->data;
        }
    }

    /**
     * Do the API request
     */
    public function do_request() {

        if ( $this->method == 'get' ) {
            $this->response_body = wp_remote_get( $this->queried_uri, $this->args );
        }

        if ( $this->method == 'post' ) {
            $this->response_body = wp_remote_post( $this->queried_uri, $this->args );
        }
    }

}
Ahmed Fouad
  • 300
  • 4
  • 14

2 Answers2

1

Before paying money and whilst using the trial credits, the message reaching you is the text: MESSAGE CONTENT Thanks for testing Clickatell's gateway coverage. You will be able to change the content of your message after your initial purchase of message credits.

This means that you have successfully sent and received a sms to your device. Your own actual messages are seen by the recipient devices only after you have paid for credits.

0

As an extension to @Dimitris Magdalinos' answer which appears to be correct, the following documentation has this to say (emphasis mine):

You can begin testing the gateway using the methods laid out in the chapter "Everyday tasks". However, please note that if you are using the 10 complimentary SMS credits which came with the account, until you have purchased credits Clickatell will replace the content with thank you text like the message below:

Thanks for testing Clickatell's gateway coverage. You will be able to change the content of your message after your initial purchase of message credits.

Community
  • 1
  • 1
Tas
  • 7,023
  • 3
  • 36
  • 51