1
votes

I have a sms api in php that i call to send sms. I pass some json and a url callback to get response status and the sms is sent.

Afterwards the server calls my callback url but i cannot get the response body. $_GET and $_POST are empty... The documentation is non existing. It should have some json. Can someone help me? Thanks in advance


    REQUEST_URI => /dev/egoi-resp.php
    GET => Array
    (
    )

    POST => Array
    (
    )

    SERVER => Array
    (
        [PATH] => /sbin:/usr/sbin:/bin:/usr/bin
        [PWD] => /usr/local/cpanel/cgi-sys
        [SHLVL] => 0
        [SCRIPT_NAME] => /dev/egoi-resp.php
        [REQUEST_URI] => /dev/egoi-resp.php
        [QUERY_STRING] => 
        [REQUEST_METHOD] => POST
        [SERVER_PROTOCOL] => HTTP/1.1
        [GATEWAY_INTERFACE] => CGI/1.1
        [REMOTE_PORT] => 45721
        [SCRIPT_FILENAME] => /home/nchaves/public_html/dev/egoi-resp.php
        [SERVER_ADMIN] => [email protected]
        [CONTEXT_DOCUMENT_ROOT] => /home/nchaves/public_html
        [CONTEXT_PREFIX] => 
        [REQUEST_SCHEME] => http
        [DOCUMENT_ROOT] => /home/nchaves/public_html
        [REMOTE_ADDR] => 94.46.251.59
        [SERVER_PORT] => 80
        [SERVER_ADDR] => 185.11.164.13
        [SERVER_NAME] => nunochaves.com
        [SERVER_SOFTWARE] => Apache
        [SERVER_SIGNATURE] => 
        [LD_LIBRARY_PATH] => /usr/local/apache/lib
        [CONTENT_LENGTH] => 166
        [HTTP_CONNECTION] => close
        [HTTP_HOST] => nunochaves.com
        [HTTP_USER_AGENT] => Java/1.7.0_25
        [HTTP_ACCEPT] => application/json
        [CONTENT_TYPE] => application/json
        [UNIQUE_ID] => VFeXf7kLpA0AB@tWLxMAAADG
        [FCGI_ROLE] => RESPONDER
        [PHP_SELF] => /dev/egoi-resp.php
        [REQUEST_TIME_FLOAT] => 1415026559.7367
        [REQUEST_TIME] => 1415026559
    )

2
we can not help you, since we do not know what your API does. Without documentation or code, how should we know, what the API need to do?vaso123
Of course you get back nothing, documentation says: Returns: voidvaso123
I add a webhook url for sms send and it gets called after an sms is sent / changes status. My trouble is how to get the response from that call in PHP.JupiterN
void is returned when i add a webhook. That is done only once.JupiterN

2 Answers

6
votes

I had the hole webhook thing working. the only trouble was to grad the json answer when the hook was called. I managed to find the answer.

$data = json_decode(file_get_contents('php://input'));

1
votes

According to the documentation:

url (string)
The URL that will be used for the Hook

actions (list)
The list of actions for which this hook is triggered.
Acceptable values: PROCESSED, SENT, DELIVERED, FAILED, CANCELED,

This URL will be used as the callback when a hook is triggered for the events you subscribed. So, lets imagine you subscribe to the SENT hook with the url http://foo.org/foo.php.

The hook related data will be sent (POST'ed) to the url -> http://foo.org/foo.php.

To see the received data I would go with this (naive) stub as a starting point:

<?php
    $f = fopen('/tmp/hook.log', 'a+');
    $d = date('Y-m-d H:i:s');
    fwrite($f, "------------- $d -----------\n");
    fwrite($f, print_r($_POST, true));
    fclose($f);
?>

Examine the /tmp/hook.log file (tail -f /tmp/hook.log) to see what is being sent.

Hope this helps, Regards, LL