I m 在a之后,试图构造一个PHP POST申请,其中包括一些双元数据。 此前的SackOverflow问题。 这些数据正在提交本年度的“:。 http://www.rixstreets.net/api/#addphoto。
这是我的PHP代码:
$file = $_FILES[ mediaupload ];
$file_field="@$file[tmp_name]";
$fields = array(
mediaupload =>$file_field,
username =>urlencode($_POST["username"]),
password =>urlencode($_POST["password"]),
latitude =>urlencode($_POST["latitude"]),
longitude =>urlencode($_POST["longitude"]),
datetime =>urlencode($_POST["datetime"]),
category =>urlencode($_POST["category"]),
metacategory =>urlencode($_POST["metacategory"]),
caption =>urlencode($_POST["description"])
);
$fields_string = http_build_query($fields);
echo FIELDS STRING: . $fields_string;
$url = https://www.cyclestreets.net/api/addphoto.json?key=$key ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec ($ch);
这是我的购买力平价文件的产出:
FIELDS STRING: mediaupload=%40%2Fprivate%2Fvar%2Ftmp%2FphpHjfkRP&username=testing&password=testing&latitude=auto&longitude=auto&datetime=auto&category=cycleparking&metacategory=good&caption=
API RESPONSE: {"request":{"datetime":"1309886656"},"error":{"code":"unknown","message":"The photo was received successfully, but an error occurred while processing it."},"result":{}}
我认为,这意味着除了双向数据的格式外,与请求有关的一切都是科索沃。 谁能告诉我我我我,我做了什么错误?