V2 API を使用して cURL 経由で Box にファイルをアップロードしようとしています。ファイルは正常にアップロードされますが、返されたオブジェクトの shared_link プロパティは null です。このシナリオを説明するドキュメントには何もないようです。このシナリオの特別な問題の 1 つは、ユーザーのサインインに古い OAuth フローをまだ使用していることです。それは V2 API が提供する機能の要因ですか? すでに OAuth2 フローへの切り替えを計画していますが、アップロード時に shared_link を取り戻す必要がある場合は、そのアップグレードの計画を加速させます。
関連するコードは次のとおりです。
209 private static $api_upload_url = 'https://upload.box.com/api/2.0/';
210 public function upload($token, $file, $folder) {
211
212 $api_key = $config['boxnet_api_key'];
213 $params = array(
214 'filename' => '@' . $file,
215 'parent_id' => $folder,
216 );
217
218 $ch = curl_init();
219 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
220 curl_setopt($ch, CURLOPT_URL, self::$api_upload_url . 'files/content');
221 curl_setopt($ch, CURLOPT_POST, 2);
222 curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
223 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: BoxAuth api_key=$api_key&auth_token=$token"));
224
225 $response = json_decode(curl_exec($ch));
226 curl_close($ch);
227
228 return $response;
229 }
以下は、応答のサニタイズされたバージョンです。
stdClass Object
(
[type] => file
[id] => /* Removed */
[sequence_id] => 0
[etag] => 0
[sha1] => /* Removed */
[name] => /* Removed */
[description] =>
[size] => 10618
[path_collection] => stdClass Object
(
[total_count] => 1
[entries] => Array
(
[0] => stdClass Object
(
[type] => folder
[id] => 0
[sequence_id] =>
[etag] =>
[name] => All Files
)
)
)
[created_at] => /* Removed */
[modified_at] => /* Removed */
[trashed_at] =>
[purged_at] =>
[content_created_at] => /* Removed */
[content_modified_at] => /* Removed */
[created_by] => stdClass Object
(
[type] => user
[id] => /* Removed */
[name] => /* Removed */
[login] => /* Removed */
)
[modified_by] => stdClass Object
(
[type] => user
[id] => /* Same as modified_by */
[name] => /* Same as modified_by */
[login] => /* Same as modified_by */
)
[owned_by] => stdClass Object
(
[type] => user
[id] => /* Same as modified_by */
[name] => /* Same as modified_by */
[login] => /* Same as modified_by */
)
[shared_link] =>
[parent] => stdClass Object
(
[type] => folder
[id] => 0
[sequence_id] =>
[etag] =>
[name] => All Files
)
[item_status] => active
)
何かご意見は?それとも、(古い方法で作成されたため) そのデータを取得するための十分な権限が認証トークンにないということですか?