我在处理从我正在使用的服务(http://Cameratag.com)发送的回调时遇到了一些问题。
我只是试图从Cameratag发送数据并用它做事。
下面是我试图开始工作的“测试”脚本..但是我正在努力找出什么是无效的。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Process_video_test extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->library('email');
}
public function index()
{
$raw = file_get_contents('php://input');
$json = json_decode($raw, true);
$uuid = $json["uuid"];
$this->email->from('Senders@email.com', 'Senders Name');
$this->email->to('Recievers@email.com');
$this->email->subject($uuid);
$this->email->message($uuid);
$this->email->send();
}
}
当我将数据重新发送到此脚本时,没有任何反应。即使您访问或卷曲此脚本的网址,它也会发送一封空白电子邮件。当我重新发送回调时,我什么也得不到。
回调服务器肯定也在POST数据,我可以在服务器日志中找到以下内容:
54.224.22.73 - - [09/Oct/2013:07:07:50 -0500] "POST /process_video_test?uuid=59fbe950-0150-0131-7bd6-22000a8fabd6&camera_uuid=732c58e0-ea3f-0130-73d4-22000aecbdd8&created_at=2013-09-16%2022%3A50%3A47%20UTC&percent_complete=100&short_code=eMOhvg&metadata[email]=Coeyman%40gmail.com&state=published&recorded_from=http%3A%2F%2Fjordan.crowdengage.com%2F&publish_type=webcam&formats[][name]=vga&formats[][width]=640&formats[][height]=480&formats[][video_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fvga%2Fmp4&formats[][mp4_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fvga%2Fmp4&formats[][webm_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fvga%2Fwebm&formats[][thumbnail_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fvga%2Fthumb&formats[][small_thumbnail_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fvga%2Fsmall_thumb&formats[][state]=COMPLETED&formats[][completed_at]=2013-09-16%2022%3A51%3A57%20UTC&formats[][name]=360p&formats[][width]=480&formats[][height]=360&formats[][video_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2F360p%2Fmp4&formats[][mp4_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2F360p%2Fmp4&formats[][webm_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2F360p%2Fwebm&formats[][thumbnail_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2F360p%2Fthumb&formats[][small_thumbnail_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2F360p%2Fsmall_thumb&formats[][state]=COMPLETED&formats[][completed_at]=2013-09-16%2022%3A51%3A58%20UTC&formats[][name]=qvga&formats[][width]=320&formats[][height]=240&formats[][video_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fqvga%2Fmp4&formats[][mp4_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fqvga%2Fmp4&formats[][webm_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fqvga%2Fwebm&formats[][thumbnail_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fqvga%2Fthumb&formats[][small_thumbnail_url]=http%3A%2F%2Fcameratag.com%2Fvideos%2F59fbe950-0150-0131-7bd6-22000a8fabd6%2Fqvga%2Fsmall_thumb&formats[][state]=COMPLETED&formats[][completed_at]=2013-09-16%2022%3A51%3A56%20UTC HTTP/1.1" 403 18156 "-" "-"
编辑:
我尝试使用以下代码作为索引文件:
类Process_video_test扩展了CI_Controller {
public function index()
{
$debug_me = 1;
$raw = file_get_contents('php://input');
$json = json_decode($raw, true);
if ($debug_me) {
ob_start();
var_dump('raw:', $raw, 'json:', $json);
log_message('info', ob_get_contents());
ob_end_clean();
}
}
在我的日志文件中有以下内容:
DEBUG - 2013-10-09 10:01:12 --> Config Class Initialized
DEBUG - 2013-10-09 10:01:12 --> Hooks Class Initialized
DEBUG - 2013-10-09 10:01:12 --> Utf8 Class Initialized
DEBUG - 2013-10-09 10:01:12 --> UTF-8 Support Enabled
DEBUG - 2013-10-09 10:01:12 --> URI Class Initialized
DEBUG - 2013-10-09 10:01:12 --> Router Class Initialized
DEBUG - 2013-10-09 10:01:12 --> No URI present. Default controller set.
DEBUG - 2013-10-09 10:01:12 --> Output Class Initialized
DEBUG - 2013-10-09 10:01:12 --> Security Class Initialized
DEBUG - 2013-10-09 10:01:12 --> Input Class Initialized
DEBUG - 2013-10-09 10:01:12 --> Global POST and COOKIE data sanitized
DEBUG - 2013-10-09 10:01:12 --> Language Class Initialized
DEBUG - 2013-10-09 10:01:12 --> Loader Class Initialized
DEBUG - 2013-10-09 10:01:12 --> Helper loaded: utility_helper
DEBUG - 2013-10-09 10:01:12 --> Helper loaded: url_helper
DEBUG - 2013-10-09 10:01:12 --> Helper loaded: menu_helper
DEBUG - 2013-10-09 10:01:13 --> Database Driver Class Initialized
DEBUG - 2013-10-09 10:01:13 --> Config file loaded: application/config/ion_auth.php
DEBUG - 2013-10-09 10:01:13 --> Email Class Initialized
DEBUG - 2013-10-09 10:01:13 --> Language file loaded: language/english/ion_auth_lang.php
DEBUG - 2013-10-09 10:01:13 --> Helper loaded: cookie_helper
DEBUG - 2013-10-09 10:01:13 --> Helper loaded: language_helper
DEBUG - 2013-10-09 10:01:13 --> Session Class Initialized
DEBUG - 2013-10-09 10:01:13 --> Helper loaded: string_helper
DEBUG - 2013-10-09 10:01:13 --> A session cookie was not found.
DEBUG - 2013-10-09 10:01:13 --> Session routines successfully run
DEBUG - 2013-10-09 10:01:13 --> Model Class Initialized
DEBUG - 2013-10-09 10:01:13 --> Model Class Initialized
DEBUG - 2013-10-09 10:01:13 --> Helper loaded: date_helper
DEBUG - 2013-10-09 10:01:13 --> REST Class Initialized
DEBUG - 2013-10-09 10:01:13 --> cURL Class Initialized
DEBUG - 2013-10-09 10:01:13 --> Controller Class Initialized
DEBUG - 2013-10-09 10:01:13 --> File loaded: application/views/includes/header.php
DEBUG - 2013-10-09 10:01:13 --> File loaded: application/views/landing.php
DEBUG - 2013-10-09 10:01:13 --> File loaded: application/views/includes/footer.php
DEBUG - 2013-10-09 10:01:13 --> File loaded: application/views/includes/template.php
DEBUG - 2013-10-09 10:01:13 --> Final output sent to browser
DEBUG - 2013-10-09 10:01:13 --> Total execution time: 0.3939
答案 0 :(得分:0)
建议您查看此Link。尝试记录您的错误。
如果您要发布数据,那么为什么要使用$raw = file_get_contents('php://input');
?只需从post
中获取数据:
$uuid = $this->input->post('uuid') //or $this->input->get('uuid'); try both once.
答案 1 :(得分:0)
我从日志中看到:DEBUG - 2013-10-09 10:01:12 --> No URI present. Default controller set.
。这意味着没有为runnig加载Process_video_test
。另外,只是从服务器的日志中看到:*.*.*.* - - [09/Oct/2013:07:07:50 -0500] "POST /process_video_test?*** HTTP/1.1" 403 18156 "-" "-"
。这意味着,您的第三方收到了HTTP错误403 Forbidden
。看起来您的服务器返回403错误,并且不加载/process_video_test
URL
打开application/config/config.php
文件并将log_threshold
参数设置为3
(信息性消息):
$config['log_threshold'] = 3;
确保将log_path
参数设置为''
,并检查默认情况下您的日志文件存储位置(只需阅读log_path
中config.php
上方的评论通过“错误记录目录路径”)。
$config['log_path'] = '';
例如,在CodeIgniter 2.1.4中,默认日志文件位置为application/logs/
。
为了发现错误,您可以记录一些调试信息并进行检查。例如,您可以稍微重写index()
:
public function index() {
$debug_me = 1;
$raw = file_get_contents('php://input');
$json = json_decode($raw, true);
if ($debug_me) {
ob_start();
var_dump('raw:', $raw, 'json:', $json);
log_message('info', ob_get_contents());
ob_end_clean();
}
//$uuid = $json["uuid"];
//$this->email->from('Senders@email.com', 'Senders Name');
//$this->email->to('Recievers@email.com');
//$this->email->subject($uuid);
//$this->email->message($uuid);
//$this->email->send();
}
打开日志文件。现在,您可以检查$raw
和$json
变量中的内容。这不是最后一步。如果您要调试,请使用记录的调试信息更新您的问题,以便我们尝试找出您的脚本有什么问题。
继续......