我所做的:我有一个带有 4 个片段的 viewpager,它们膨胀包含 RecyclerView 的相同布局。我为所有片段构建了一个适配器。当我单击一个项目时,它会加载数据并将数据附加到列表并将新数据设置到适配器。
问题:问题是当我更改特定片段的特定 recyclerview 的数据时,更改会对所有 recyclerview 生效。
我正在尝试使用 Box API 将文件上传到 box.com。根据文档,curl 请求必须如下所示:
curl https://upload.box.com/api/2.0/files/content \
-H "Authorization: Bearer ACCESS_TOKEN" -X POST \
-F attributes='{"name":nameOftheFile, "parent":{"id":parentId}}' \
-F file=@file
Run Code Online (Sandbox Code Playgroud)
这是我所做的:
$token = "......";
$url = https://upload.box.com/api/2.0/files/content;
$file_upload;
foreach ($_FILES['file']['name'] as $position => $file) {
$file_upload = $_FILES['file']['tmp_name'][$position];
}
$json = json_encode(array('name' => $file ,array('parent' => array('id' => 0))));
$attrs = array('attributes' => $json,'file'=>'@'.$file_upload);
$this->post($url,($attrs));
// Post function
function post($url,$fields){
try {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$this->token
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, …Run Code Online (Sandbox Code Playgroud)