Onedrive перестал создавать папкиPhp

Кемеровские программисты php общаются здесь
Ответить
Гость
 Onedrive перестал создавать папки

Сообщение Гость »


Недавно я реализовал API Graph, чтобы:
Создать в общей папке различные каталоги с такими именами => "uc_123455";
в каждой созданной папке API загружает в него PDF-файлы.
Проблема:
Все запускается нормально, но через некоторое время просто перестает создавать папку, всего в ней почти Необходимо создать 2323 папки и прекратить создание после 1000.
Код работает следующим образом:
Сначала он получает

Код: Выделить всё

access_token
from Microsoft and load the Graph then get the shared folder ID.

Код: Выделить всё

$this->graph = new Graph();
$this->graph->setAccessToken($this->accessToken);
$this->directory_id = $this->fetchDirectoryId($this->graph);
then it start looping:
First it create the name based on what part is of the loop

Код: Выделить всё

$subfolderName = "UC_" . $customer->numero_uc;
after this is used to create the folder on this function

Код: Выделить всё

$folder = $this->createIntoDirectory($this->directory_id[0], $this->graph, $subfolderName);
and this function works like this

Код: Выделить всё

public function createIntoDirectory(string $folderId, Graph $graph, string $ucNumber): string|bool
{
try {
$response = $graph->createRequest('POST', "/me/drives/" . $this->drive_id . "/items/$folderId/children")
->attachBody(json_encode([
"name" => $ucNumber,
"folder" => new stdClass()
], JSON_THROW_ON_ERROR))
->setReturnType(DriveItem::class)
->execute();
return $response->getId();
} catch (GuzzleException|GraphException) {
return $this->fetchExistenteDirectory($folderId, $graph, $ucNumber);
}
}
if already exist an Folder with the name it falls in the exception and call to another function that return the id of the already created folder (I did this in case any PDFs weren't sent to the folder).
Here the function:

Код: Выделить всё

public function fetchExistenteDirectory(string $folderId, Graph $graph, string $ucNumber): string|bool
{
try {
$folder = $graph->createRequest('GET', "/me/drives/" . $this->drive_id . "/items/$folderId/children")
->setReturnType(DriveItem::class)
->execute();
foreach ($folder as $item) {
if ($item->getName() === $ucNumber) {
return $item->getId();
}
}
return false;
} catch (GuzzleException|GraphException) {
return false;
}
}
Are there problems with my code to stop generation folders, because it works 100% fine, until then it stops?
Questions:

Where is the PDF? The PDF are converted images from URLs that I fetch from my database.
What is a UC?: is like users, it come from Portuguese word "unidade consumidora" or "consumer unit", each of then come from an array that I fetch from my database.
If you have any questions about the code or the process just ask.
(English isn't my mother tongue, so sorry for any grammatical error).
I tried to create a loop using sleep or increasing time of execution on my PHP but still nothing.


Источник: https://stackoverflow.com/questions/781 ... ng-folders
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»