下面是我在数据上传程序中使用的代码。
if(isset($_POST['upload'])){
try {
$dailyUploadsFile = $analytics->management_dailyUploads->upload(
$_REQUEST['accountId'], // your accountID
$_REQUEST['webPropertyId'], // your web property ID
$_REQUEST['customDataSourceId'], // your custom data source UID
$_REQUEST['datepicker'], // date
$_REQUEST['appendNumber'], // append number
'cost', // type of data
array(
"reset" => $_REQUEST['reset'],
"data" => file_get_contents_curl($_REQUEST['csvFile']),
"mimeType" => 'application/octet-stream',
"uploadType" => 'media'));
} catch (Exception $e) {
die('An error occured: ' . $e->getMessage()."\n");
}
}
这是我点击提交时遇到的错误:
发生错误:调用 POST 时出错https://www.googleapis.com/upload/analytics/v3/management/accounts/34620205/webproperties/UA-34620205-1/customDataSources/P4Zlk69kSCOtVVIu7iFjqw/dailyUploads/2013-03-09/uploads ?appendNumber=1&type=cost&reset=true&uploadType=media&key=AIzaSyDzvHpTNC_CKAnpyfnc1Vjwl_joE5hgBhc : (400) 不支持媒体类型“application/x-www-form-urlencoded”。有效的媒体类型:[application/octet-stream]
请帮忙。