Implementing Instagram Share Functionality in Spring Boot Project

I’m currently working on a feature for our blogging project that allows users to share post links on various social media platforms, including Facebook, Instagram, and Telegram.

I’ve successfully implemented sharing via Telegram using the following format:
https://t.me/share/url?url=${encodeURIComponent(text)}&text=${encodeURIComponent('Check this out!')}

However, I need assistance with implementing a similar sharing feature for Instagram, particularly to allow users to share post links directly to Instagram DMs, stories, or posts. So far, I haven’t found a straightforward way to achieve this, as Instagram’s API and sharing mechanisms differ from other platforms.

Could anyone provide guidance or suggestions on how to create shareable links for Instagram, or share their experiences if they’ve tackled a similar issue?

For Instagram, I attempted to use the intent:// scheme to copy the link to the clipboard and then redirect to the Instagram app. Here’s the code I used:

    var dummy = document.createElement("textarea");
    const text = window.location.href;
    document.body.appendChild(dummy);
    dummy.value = text;
    dummy.select();
    document.execCommand("copy");
    document.body.removeChild(dummy);
    window.location.href = `intent://send?text=${encodeURIComponent(text)}#Intent;scheme=instagram;package=com.instagram.android;end`;

    setTimeout(function () {
        if (document.visibilityState === "visible") {
            window.location.href = `https://www.instagram.com/direct`;
        }
    }, 100);
}

I expected that this approach would either:

Open the Instagram app with a prompt to share the link directly in a DM, or
Open the Instagram app with a prompt to share the link as a story or post.
However, it appears that Instagram’s current API and sharing mechanisms might not support direct sharing of links in this manner. I am looking for a more reliable way to achieve the desired functionality, or any alternative methods that could be used for sharing content on Instagram.