0
我知道這可能是一個非常虛擬的問題,但我面對PHP的一個需求,我已經做了一些非常簡單的事情,但現在我真的需要幫助。使用PHP調用一個URL併發送參數作爲POST
我有這樣的場景:
我使用以下URL調用Java休息WS:
http://192.168.3.41:8021/com.search.ws.module.ModuleSearch/getResults/jsonp?xmlQuery=%3C?xml%20version%3D'1.0'%20encoding%3D'UTF-8'?%3E%3Cquery%20ids%3D%2216535%22%3E%3CmatchWord%3Ehave%3C/matchWord%3E%3CfullText%3E%3C![CDATA[]]%3E%3C/fullText%3E%3CquotedText%3E%3C!...
但對於這一點,我不得不使用Java的Util類來代替某些特殊字符在XML參數,因爲原始XML是一樣的東西:
<?xml version='1.0' encoding='UTF-8'?><query ids="16914"><matchWord>avoir</matchWord><fullText><![CDATA[]]></fullText><quotedText><![CDATA[]]></quotedText><sensitivity></sensitivity><operator>AND</operator><offsetCooc>0</offsetCooc><cooc></cooc><collection>0</collection><searchOn>all</searchOn><nbResultDisplay>10</nbResultDisplay><nbResultatsParAspect>...
現在,我一直要求創建一個PHP頁面中,我可以將XML作爲輸入,並請求對REST WS美國提交按鈕。我做了一個方法,但不是似乎工作,在這裏我貼我的代碼:
<?php
if($_POST['btnSubmit'] == "Submit")
{
$crudXmlQuery = $_POST['inputXml'];
echo $crudXmlQuery;
echo "=================================================";
$xml = str_replace("%", "%25", $crudXmlQuery);
$xml = str_replace("&", "%26", $crudXmlQuery);
$xml = str_replace("=", "%3D", $crudXmlQuery);
echo $xml;
//$ch = curl_init($url);
//curl_setopt ($ch, CURLOPT_POST, 1);
//curl_setopt ($ch, CURLOPT_POSTFIELDS,'inputXml='.$xml);
//$info = curl_exec ($ch);
//curl_close ($ch);
}
?>
<form action="sampleIndex.php" method="post">
Please insert your XML Query
<input type='text' name='inputXml' value='<?=$crudXmlQuery?>'/>
<input type='submit' name='btnSubmit' value='Submit' />
</form>
我評論捲曲的部分,因爲它給了我一些問題,我不知道如何處理這個要求還沒有,如果有人能幫助我,我會非常感激。提前致謝。最好的祝福。
是的,我錯過了當我從我的編輯器複製粘貼時,但我正如你所提到的,但是當我執行「這個回聲」時,它顯示我奇怪的字符,而不是我放在文本字段中的xml。 –
你能複製粘貼怪異字符嗎? –
這些是我執行回聲時打印的字符:avoirAND00all10580date0082.122.169.2440false3.0.51tcbet30] IND –