Use var_dump($ogimage);
to understand the contents of $ogimage
presumably it’s returning an array of records from the database.
Generally you would retrieve post meta values with get_post_meta
WordPress Docs for get_post_meta()
Also there are plugins that sort out the og tags for you such as Yoast SEO