Instagram\Instagram::commentOnMedia PHP Method

commentOnMedia() public method

Comment on Media
public commentOnMedia ( string | FeedItem $mediaId, string $comment ) : CommentMediaResponse
$mediaId string | Instagram\API\Response\Model\FeedItem FeedItem or FeedItem Id to Comment on
$comment string Comment
return Instagram\API\Response\CommentMediaResponse
    public function commentOnMedia($mediaId, $comment)
    {
        if (!$this->isLoggedIn()) {
            throw new InstagramException("You must be logged in to call commentOnMedia().");
        }
        if ($mediaId instanceof FeedItem) {
            $mediaId = $mediaId->getPk();
        }
        $request = new CommentMediaRequest($this, $mediaId, $comment);
        $response = $request->execute();
        if (!$response->isOk()) {
            throw new InstagramException(sprintf("Failed to commentOnMedia: [%s] %s", $response->getStatus(), $response->getMessage()));
        }
        return $response;
    }