0
我正在使用以下代码来查找用户的所有属性,然后删除它们。我的问题是,我收到警告:警告:sprintf():每个属性的参数太少。sprintf警告 - 编码问题
然而,当我手动输入$ USER_ID进行删除字符串作为FIRST_LAST %% 40ourwiki.com它的作品!
似乎像sprintf需要双'%'但不知道为什么。有没有办法解决这个问题?此外,我使用file_get_contents相同的变量,这工作正常。
验证码:
$user="[email protected]";
$user_id=str_replace(array('@', '#'), array('%40', '%23'), $user);
print $user_id;
$url=("http://admin:[email protected]/@api/users/=$user_id/properties");
$xmlString=file_get_contents($url);
$delete = "http://admin:[email protected]/@api/users/=$user_id/properties/%s";
$xml = new SimpleXMLElement($xmlString);
function curl_fetch($url,$username,$password,$method='DELETE')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
return curl_exec($ch);
}
foreach($xml->property as $property) {
$name = $property['name'];
$name2=str_replace(array('@', '#'), array('%40', '%23'), $name);
print $name2;
curl_fetch(sprintf($delete, $name2),'admin','password');
}
提前感谢!
非常感谢你,这似乎是为我工作:) – Aaron 2010-10-02 19:26:36