私は Box 環境にまったく慣れていません。現在のコードを使用して、サイトの Web ディレクトリにあるすべての画像を、最新のファイルが最初に表示されるように表示しています。
<?php
$path = 'images/';
$files = scandir($path);
$ignore = array( 'cgi-bin', '.', '..');
# remove ignored files
$files = array_filter($files, function($file) use ($ignore) {return !in_array($file, $ignore);});
# get the modification time for each file
$times = array_map(function($file) use ($path) {return filemtime("$path/$file");}, $files);
# sort the times array while sorting the files array as well
array_multisort($times, SORT_DESC, SORT_NUMERIC, $files);
foreach ($files as $file) {
echo '<div class="item">';
echo '<a title="©2013" rel="gallery" class="fancybox" href="images/'.$file.'"><img src="images/'.$file.'" alt="'.$image.'" /></a>';
echo '</div>';
}
?>
Box API を統合して、Web フォルダーではなく Box フォルダーからファイルを取得したいと考えています。これは現在の API で可能ですか? Open Access フォルダの内容を次のように表示しようとしました。
<?php
$params = array();
$params['shared_link'] = array("access"=> "Open");
$params = json_encode($params);
echo $params;
$key = "[my api key]";
$token = "[token]";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.box.com/2.0/folders/kvpemb6rgohhr448r935"); //my box folder
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', "-H Authorization: Bearer $key",'Content-Length: ' . strlen($params), 'X-HTTP-Method-Override: GET'));
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
?>
ただし"{"shared_link":{"access":"Open"}}"
、ページ上の配列値のみを受け取ります。
私は Google と Stackoverflow での検索能力を使い果たしましたが、このタスクを達成しようとするスレッドに遭遇していません。ご指導/ご協力ありがとうございます。