如何获得来自其他API回调调用的响应
我有一个短信API,我打电话来发送短信。 我传递一些json和url回调来获得响应状态,并发送短信。
之后服务器调用我的回调url,但我无法获得响应正文。 $ _GET和$ _POST为空...文档不存在。 它应该有一些JSON。 有人能帮我吗? 提前致谢
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] => webmaster@nunochaves.com [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 )
我有洞webhook的工作。 唯一的麻烦是在钩子被调用时修改json的答案。 我设法找到答案。
$ data = json_decode(file_get_contents('php:// input'));
根据文件:
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,
当您订阅的事件触发挂钩时,此URL将用作回调。 因此,让我们想象你订阅URL为http://foo.org/foo.php
的SENT
钩子。
钩子相关的数据将被发送( POST
)到url - > http://foo.org/foo.php
。
为了查看收到的数据,我会以这个(天真的)存根作为出发点:
<?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);
?>
检查/tmp/hook.log
文件( tail -f /tmp/hook.log
)以查看正在发送的内容。
希望这有助于,关心,LL
链接地址: http://www.djcxy.com/p/8595.html