将Instagram页面地址转换为用户名

I have a web form, in this form my customers will put their Instagram page addresses, then I must export the username from the link but I have a problem people will put this addresses in some ways for example:

https://instagram.com/username/
instagram.com/username/
https://instagram.com/username?igshare....
https://instagram.com/u/username
username

I am trying to found an api for this work I send the link to the api, then it convert the link to username Instagram hasn't this api, do you know which have this api?

You could do without an API using the parse_url() and substr() functions to respectively extract "/username" out of "instagram.com/username" and removing the slash at the start, like so:

//assuming you pass the URL to another page using a POST request
$url = $_POST['url'];
$username = substr(parse_url($url, PHP_URL_PATH), 1);