Пример #1
0
error_reporting(E_ERROR);
$reqcontext = file_get_contents("php://input");
$TfbAuthRequest = new TfbAuthRequest();
$Publiccls = new PublicClass();
//初始化类实例
set_error_handler('my_error_handler');
$reqxmlcontext = $TfbAuthRequest->getReqContext($reqcontext);
//解密并获得请求数据
$arr_xml = $Publiccls->xml_to_array($reqxmlcontext);
$authorid = $arr_xml['operation_request']['msgheader']['channelinfo']['authorid'];
$arr_authorinfo = AuToken::getauthorusername($authorid);
$authortruename = $arr_authorinfo['username'];
$file = "../../" . CONST_LOGDIR . "/" . date('md') . "-" . $authortruename . "log" . ".txt";
$filehandle = fopen($file, "a");
$now = date('Y-m-d H:i:s');
fwrite($filehandle, $now . "\r\n======请求内容:\r\n" . $reqcontext . "\r\n\r\n" . $reqxmlcontext);
fclose($filehandle);
$apiAutoken = $TfbAuthRequest->apiAutoken($reqxmlcontext);
//授权码等信息验证
if ($apiAutoken && $api_name && $api_name_func) {
    spl_autoload_register(array('Loader', 'loadClass'));
    $classname = $api_name;
    $ApiClass = new $classname();
    $returnvalue = $ApiClass->{$api_name_func}();
    echo $returnvalue;
} else {
    $ErrorReponse = new ErrorReponse();
    $Error = array('result' => 'failure', 'retcode' => '404');
    $ErrorReponse->reponError($Error);
    //出错反馈
}