i'm using api sms provider (yes, needs provider i'm stuck it), documentation leaves lot desired, , includes examples , support.
i'm trying figure out different callbacks have no idea they're sending back. there way write php script captures incoming responses file. responses (but not exclusively), wanna send couple calls (both correct , errors) , record get.
{ "api_job_id":"4c2478d3-aebb-4510-8720-1b479d01cfd5", "client_job_id":"abc123456", "data":[ { "type":"sms", "message_id":"14182390945378443202", "status":"sent", "timestamp":1422885283, "micro_timestamp":1422885283477, "to":"xxxxxxxxx", "from":"companya", "client_message_id":"2", "error_code":0 } ] }
this might looking for:
<?php $logfile = dirname(__file__).'/smscallback.log'; // change if necessary foreach($_get $key => $value) { $header = 'callback_key: "' . $key . '", received: ' . gmdate('y-m-d h:i:s') . ' (utc)'. ', contents:' . php_eol; if (version_compare(php_version, '5.4.0') >= 0) { $tmparray = (array)json_decode($value); $json = json_encode($tmparray, json_pretty_print); } else { $json = $value; } file_put_contents($logfile, $header . $json. php_eol . php_eol, file_append); echo "saved file '$logfile'"; } // http://www.example.com/smscallback.php?callbck1={"api_job_id":"4c2478d3-aebb-4510-8720-1b479d01cfd5","client_job_id":"abc123456","data":[{"type":"sms","message_id":"14182390945378443202","status":"sent","timestamp":1422885283,"micro_timestamp":1422885283477,"to":"xxxxxxxxx","from":"companya","client_message_id":"2","error_code":0}]} ?>
the script accepts parameters. writes (appends) key, current date , time (utc) plus values of parameters log file on server.
note: web server must have write privileges log file, of course.
Comments
Post a Comment