php对提交数据转码,如何使用php程序实现媒体转码消息的接收
媒體轉碼的轉碼任務是異步的接口,提交轉碼任務后,可以通過消息通知功能,接收轉碼任務結果。
詳細說明參見:【點此查看】
由于目前消息接受URI必須為/notifacations,所以如果使用php處理消息的話,需要在web服務器上配置rewite。
以nginx為例,需要在配置中添加紅色的一行,(revive_msg.php為實際接收轉碼任務消息的php頁面)
server {
listen?????? 80;
server_name? localhost;
index index.html index.htm index.php;
root /www/php;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
rewrite "^/notifications$" /revive_msg.php break;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass? unix:/tmp/php-cgi.sock;
fastcgi_pass? 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|exe)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
location ~ .*\.(txt)?$
{
add_header??? Cache-Control? no-cache;
}
修改后,重啟nginx是配置生效,這樣當消息推送到/notifacations時,實際會由revive_msg.php進行處理。
附 消息處理的php代碼:
//$xml = $HTTP_RAW_POST_DATA;
$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
//將xml數據寫入文本文件"msg.txt"中,實際處理時,可以解析XML后根據任務執行結果進行后續的處理
$handle? = fopen('msg.txt','a+');
fwrite($handle,$xml);
//返回狀態必須為204,不能是200或其他的狀態碼,否則會認為消息推送失敗
http_response_code(204);
?>
如果問題還未能解決,請聯系
總結
以上是生活随笔為你收集整理的php对提交数据转码,如何使用php程序实现媒体转码消息的接收的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php curl_multi_close
- 下一篇: php调用应用程序api,使用PHP调用