我不知道该怎么做。我试图在我的函数内部使用我的字符串进行会话并解析其外部的会话,如果这是有道理的......但我得到这个错误“SimpleXMLElement”不允许在session_write_close()“任何关于我的建议可以做到解决吗?
function api_info($form, &$form_state){
$server_url = 'website api url'
curl_setopt($ch, CURLOPT_URL, $server_url );
curl_setopt($ch, CURLOPT_POST, 0 );
curl_setopt($ch, CURLOPT_POSTFIELDS, );
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:") );
curl_setopt($ch, CURLOPT_FAILONERROR, 1 );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, );
curl_setopt($ch, CURLOPT_HEADER, false );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt($ch, CURLOPT_TIMEOUT, 120 );
curl_setopt($ch, CURLINFO_HEADER_OUT, true );
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
$xml_response_lead_point = curl_exec($ch);
$xml_request_lead_point = new SimpleXMLElement($xml_response_lead_point);
$result = reset($xml_request_lead_point->sm);
$xml_request = $xml_request_lead_point;
$xml_results = array(
'lead_response' => $result,
'results' => $xml_request,
);
//dvm($xml_results['results']);
//dvm($xml_request_lead_point);
//dvm($a);
$_SESSION['lead_results'] = $xml_results['results'];
return $xml_results;
}
$lead_results = $_SESSION['lead_results'];
var_dump($lead_results);
答案 0 :(得分:1)
您需要serialize()
SimpleXMLElement(或任何对象),然后才能将其存储在会话中,然后unserialize()
使用它。
$xml_obj = new SimpleXMLElement( $xml_string );
$_SESSION['xml_value'] = serialize( $xml_obj );
$xml_obj2 = unserialize( $_SESSION['xml_value'] );
或者,您可以保存用于创建对象的XML字符串。