Reputation: 2053
I'm using microsoft's graph api to upload files to onedrive. If the upload is successful, I'd like to delete the local file. My code is as follows:
public function testMoveFile()
{
$graph = new Graph();
$graph->setAccessToken($acccess_token);
$response = $graph->createRequest("PUT", "/drives/$drive_id/items/root:/$filename:/content")
->attachBody($content)
->execute();
if ($response->getStatusCode() > 201) {
var_dump($response);
} else {
// remove the file
}
}
The problem is that there doesn't appear to be a getter for the response http status code. When I use var_dump()
to examine $response
, I can see that there is a private property called _httpStatusCode
, but when I try to access it, I get an error because it is private. When I looked through the unit tests, I don't see any checking. Is there another way to do it?
Upvotes: 2
Views: 945
Reputation: 2053
This was easier than I thought. To get the status code, you have to
if ($response->getStatus() > 201) {
Upvotes: 2