Instagram\Instagram::postPhoto PHP Method

postPhoto() public method

Post Photo to Timeline
public postPhoto ( string $path, string $caption = null ) : ConfigureMediaResponse
$path string File path of Photo to Post
$caption string Caption for this Photo
return Instagram\API\Response\ConfigureMediaResponse
    public function postPhoto($path, $caption = null)
    {
        if (!$this->isLoggedIn()) {
            throw new InstagramException("You must be logged in to call postPhoto().");
        }
        $request = new PhotoUploadRequest($this, $path);
        $response = $request->execute();
        if (!$response->isOk()) {
            throw new InstagramException(sprintf("Failed to Upload Photo: [%s] %s", $response->getStatus(), $response->getMessage()));
        }
        $request = new ConfigureMediaRequest($this, $response->getUploadId(), $path, $caption);
        $response = $request->execute();
        if (!$response->isOk()) {
            throw new InstagramException(sprintf("Failed to Configure Media: [%s] %s", $response->getStatus(), $response->getMessage()));
        }
        return $response;
    }