我想正确地将一个cURL命令转换为PHP,但我似乎无法找到正确的命令。我可以用cURL运行这个命令,但我需要通过TROPO来运行它,并且它们只有几个脚本选项。cURL到PHP等效
所以我想在PHP中。
curl https://api.particle.io/v1/devices/310029000547353138383138/setNum \ -d access_token=e650d0dec0476de7d64b23110fed31dcb3cbxxxx \ -d args=2085555555
我的尝试,我错过了什么?
<?php
function submitValue() {
$ch = curl_init("https://api.particle.io/v1/devices/310029000547353138383138/setNum");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, 'access_token=e650d0dec0476de7d64b23110fed31dcb3cbxxxx&"args=2085555555"');
);
$output = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != '200') {
return null;
}
return $output;
}
?>
是'*>'错字还是出现在您的原始代码? (应该是'?>') –
@Matt有趣的是,'*'和'?'在键盘上远离彼此。那么它怎么会是一个**错字** – nmnsud
@nmnsud:D我的意思是,当然是原始代码中的错误,或者是在将它转录到堆栈溢出时引入的? –