0

我正在尝试通过 HTTP POST 方法发布 xml...代码工作正常并显示所需的消息..“数据接收成功”..问题是,在后端查找时,数据未发布在议程创意后端..我在哪里搞砸了?提前谢谢。

<?php   

function sendXmlOverPost($url, $xml) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

 // For xml, change the content-type.
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // ask for results to be returned

  // Send to remote and return data to caller.
 $result = curl_exec($ch);
 curl_close($ch);
 return $result;
 }

 $postargs = '<?xml version="1.0" encoding="utf-8"?>
 <Vacancy>
 <Poster>LOGICMELON</Poster>
 <Action>Add</Action>
 <Username>agendacreative</Username>
 <Password>A12!.ndasa55</Password>
 <JobReference>AC Test 1</JobReference>
 <JobTitle>AC Test 1</JobTitle>
 <JobType>F</JobType>
 <JobHours>F</JobHours>
 <Industry>137</Industry>
 <SalaryCurrency>GBP</SalaryCurrency>
 <SalaryFrom>100.0000</SalaryFrom>
 <SalaryTo>200.0000</SalaryTo>
 <SalaryPer>D</SalaryPer>
 <SalaryBenefits>Benefits</SalaryBenefits>
 <Salary>£100 - 200 per day + Benefits</Salary>
 <JobLocation>4</JobLocation>
 <JobCountry>GB</JobCountry>
 <JobDescription>&lt;p&gt;LOGIC MELON TEST VACANCY - PLEASE DO NOT APPLY!!!&lt;/p&gt;&lt;p&gt;Testing the initial integration to Agenda Creative to make sure that the template is compiled properly andt hat the fields are getting sent through correctly.&lt;/p&gt;&lt;p&gt;THIS IS A LOGIC MELON TEST VACANCY - PLEASE DO NOT APPLY FOR THIS ROLE AS IT DOES NOT EXIST!!!&lt;/p&gt;&lt;p&gt;&amp;euro; - Testing Euro Sign&lt;/p&gt;&lt;p&gt;&amp;pound; - Testing Pound Sign&lt;/p&gt;</JobDescription>
<ContactName>Logic Melon Support</ContactName>
<ContactEmail>jade.sinclair.1267EC41.0@applythis.net</ContactEmail>
<ApplicationEmail>jade.sinclair.1267EC41.0@applythis.net</ApplicationEmail>
<ApplicationURL></ApplicationURL>
<WeeksToAdvertise>1</WeeksToAdvertise>
</Vacancy>
';
    $request = "http://agendacreativerecruitment.co.uk/feed.php";
    echo (sendXmlOverPost($request, $postargs));
?>
4

1 回答 1

0

我不知道议程创意。但是尝试这样的事情?

curl_setopt($ch, CURLOPT_POSTFIELDS, array('xml' => $xml));

其中“xml”是您的 xml 数据应位于的 post 字段。

于 2013-09-28T08:13:17.650 回答