bind php,http-bind.php

/**

* 在线客服聊天系统前端请求转发拦截器

* $Author: 鸿宇多用户商城

*/

define('IN_ECS', true);

require (dirname(__FILE__) . '/includes/init.php');

// file_put_contents("D:/php.debug",

// var_export(file_get_contents("php://input")."\n", true), FILE_APPEND);

// 获取页面提交的数据

$input = file_get_contents("php://input");

if(empty($input))

{

print('');

return;

}

// 解析消息

$xml = simplexml_load_string($input);

if(! empty($xml->response))

{

$response = $xml->response;

$response_plain = base64_decode($response);

// $response_plain = str_replace('==from==', $_SESSION['OF_FROM'],

// $response_plain);

$response_plain = str_replace('==to==', $_SESSION['OF_TO'], $response_plain);

$xml->response = base64_encode($response_plain);

// file_put_contents("D:/php.debug", $response_plain, FILE_APPEND);

$input = $xml->asXML();

// 根据用户名称判断当前用户是否为此用户并且是否已经登录

// 判断此用户是否已经注册,未注册则需要先到聊天服务器进行注册

}

else if(! empty($xml->message))

{

$message = $xml->message;

$message->attributes()->from = $_SESSION['OF_FROM'];

$message->attributes()->to = $_SESSION['OF_TO'];

$message->body = $message->body;

$input = $xml->asXML();

// file_put_contents("D:/php.debug",

// var_export($xml."--->>>".$_SESSION['OF_TO']."--->>>".$_SESSION['OF_FROM'],

// true), FILE_APPEND);

}

else

{

$input = $xml->asXML();

}

$_CFG = $GLOBALS['_CFG'];

$of_ip = $_CFG['chat_server_ip'];

$http_bind_port = $_CFG['chat_http_bind_port'];

$of_url = "http://$of_ip:$http_bind_port/http-bind/";

// 初始化curl

$ch = curl_init();

// 抓取指定网页

curl_setopt($ch, CURLOPT_URL, $of_url);

// 设置header

curl_setopt($ch, CURLOPT_HEADER, 0);

// 要求结果为字符串且输出到屏幕上

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// post提交方式

curl_setopt($ch, CURLOPT_POST, 1);

// 提交的数据

curl_setopt($ch, CURLOPT_POSTFIELDS, $input);

// 运行curl

$data = curl_exec($ch);

// 关闭

curl_close($ch);

//file_put_contents("D:/php.debug", $of_url."\n".$data."\n", FILE_APPEND);

// 输出结果

print_r($data);

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值