$getAttachmentURL
ファイルをダウンロードできるように、添付ファイルの URL を取得しようとしています。エラー コード 1006 が表示されます - 見つかりません。
<?php
$baseURL = "https://api.smartsheet.com/1.1";
$sheetsURL = $baseURL."/sheets/";
$getSheetURL = $baseURL."/sheet/3712544801089412";
$rowsURL = $baseURL."/sheet/3712544801089412/rows";
$rowAttachmentsURL = $baseURL."/sheet/3712544801089412/row/{{ROWID}}/attachments";
$getAttachmentURL = $baseURL."/sheet/3712544801089412/attachment/{{ATTACHMENTID}}";
// Insert your Smartsheet API Token here
$accessToken = "xxx";
// Create Headers Array for Curl
$header = array(
"Authorization: Bearer ".$accessToken,
"Content-Type: application/json"
);
// Connect to Smartsheet API to get Selected Sheet
$curlSession = curl_init($getSheetURL);
curl_setopt($curlSession, CURLOPT_HTTPHEADER, $header);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, TRUE);
$getSheetResponseData = curl_exec($curlSession);
$sheetObj = json_decode($getSheetResponseData);
echo "<h1>Sheet name: ".$sheetObj->name."</h1>";
echo "<br>";
//table start
echo "<table>";
echo "<td>"."Attachment"."</td>";
foreach($sheetObj->columns as $column) {
echo "<td>".$column->title."</td>";
}
echo "<tr>";
foreach($sheetObj->rows as $row) {
$rowAttachmentsURL = str_replace('3712544801089412', $row->id, $rowAttachmentsURL);
$chosenRow = $row->id;
$rowAttachmentsURL = $baseURL."/sheet/3712544801089412/row/$chosenRow/attachments";
$rowAttachmentsURL = str_replace($chosenRow, $row->id, $rowAttachmentsURL);
$curlSession = curl_init($rowAttachmentsURL);
$rowsResponse = curl_exec($curlSession);
// Assign response to variable
$addRowsObj = json_decode($rowsResponse);
curl_setopt($curlSession, CURLOPT_HTTPHEADER, $header);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, TRUE);
$getAttachmentsResponse = curl_exec($curlSession);
// Assign response to variable
$attachment = json_decode($getAttachmentsResponse);
$rowAttachTags = array($chosenRow->id, $theSheet->id, $attachments[0]->id);
$rowAttachVals = array($addRowsObj->result[0]->id, $theSheet->id, $attachments[0]->id);
$getAttachmentURL = str_replace($rowAttachTags, $rowAttachVals, $getAttachmentURL);
$type = $attachment[0]->mimeType;
$size = $attachment[0]->sizeInKb;
$filename = $attachment[0]->name;
// Print headers
header("Content-Type: $type");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=$filename");
echo "<td><a href='".$getAttachmentURL."'>".$attachment[0]->name."</a></td>";
//echo "<td>".$attachment[0]->id."</td>";
foreach($row->cells as $cell) {
echo "<td>".$cell->value."</td>";
}
echo "<td></td><td></td><td></td>";
echo "</tr>";
}
echo "</table>";
私は少し混乱しています。すべてを中止するので、本当にあなたの助けが必要です