<?php
$xml = '
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<AddAdvert xmlns="http://api.logicmelon.com/">
//我试图将数据写入下面的字段。
<sCultureID>string</sCultureID>
<sAPIKey>string</sAPIKey>
<sUsername>string</sUsername>
<sPassword>string</sPassword>
<sAdvertIdentifier>string</sAdvertIdentifier>
<sAdvertReference>string</sAdvertReference>
<sSearchDays>string</sSearchDays>
<sOnDuplicate>string</sOnDuplicate>
<sJobTitle>string</sJobTitle>
<sJobType>string</sJobType>
<sJobHours>string</sJobHours>
<sPrimaryLocation>string</sPrimaryLocation>
<sIndustry>string</sIndustry>
<sSalaryFrom>string</sSalaryFrom>
<sSalaryTo>string</sSalaryTo>
<sSalaryCurrency>string</sSalaryCurrency>
<sSalaryPer>string</sSalaryPer>
<sSalaryBenefits>string</sSalaryBenefits>
<sContactName>string</sContactName>
<sContactEmail>string</sContactEmail>
<sJobDescription>string</sJobDescription>
<sApplicationURL>string</sApplicationURL>
<DestinationsAsCSV>string</DestinationsAsCSV>
<sRedirectDomain>string</sRedirectDomain>'
($_POST)
$url = 'http://api.logicmelon.co.uk/SOAP/multiposter.asmx?op=AddAdvert';
$fields = array(
'sCultureID' => urlencode($sCultureID),
'sAPIKey' => urlencode($sAPIKey),
'sUsername' => urlencode($sUsername),
'sPassword' => urlencode($sPassword),
'sJobTitle' => urlencode($sJobTitle),
'sJobType' => urlencode($sJobType),
'sIndustry' => urlencode($sIndustry)
);
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);
?>
答案 0 :(得分:2)
更改
<sRedirectDomain>string</sRedirectDomain>'
到
<sRedirectDomain>string</sRedirectDomain>';
并且,删除($ _POST),或者用它做一些有意义的事情。这不会为您的脚本添加任何内容。你是否从其他地方复制粘贴?
除此之外;阅读这样的页面应该是好的:http://www.w3schools.com/php/php_syntax.asp,以便更好地了解这些错误可能是由什么造成的。