Get category id from post id of a custom post type

I want to get category id from post id of a custom type.
I have the post id, but I can’t get it’s category id.

I have used so many codes but it doesn’t work, may be due to custom post type.

$category = get_the_category( $post->ID );

Any suggestions?

Solutions Collecting From Web of "Get category id from post id of a custom post type"

wp_get_post_categories can only get POST categories not a custom post’s categories, try this instead:

$category = get_the_terms( $post->ID, 'custom-taxonomy-here' );     
foreach ( $category as $cat){
   echo $cat->name;
}

Check this link

Are your custom post type supporting the standard category taxonomy? If the category used in your custom post type is a custom taxonomy and not the standard category taxonomy you should get_the_terms() instead of get_the_category().

$categories = get_the_terms($post->ID, "my-custom-taxonomy");