• Resolved Junior Miranda

    (@jmjunior)


    Hello folks.

    My REST API is returning the Instagram data-shortcode attribute empty. Bellow follows the code of the post content rendering:

    
    private function get_the_content()
        {
            ob_start();
            the_content();
            $content = ob_get_clean();
    
            $sanitizers = amp_get_content_sanitizers();
    
            $embeds = apply_filters('amp_content_embed_handlers', array(
                'AMP_Instagram_Embed_Handler' => array(),
                'AMP_Twitter_Embed_Handler' => array(),
                'AMP_Facebook_Embed_Handler' => array(),
            ));
    
            $amp_content = new \AMP_Content($content, $embeds, $sanitizers);
    
            $html = $amp_content->get_amp_content();
    
            // more links
            $more = new MoreLinks();
    
            $handler = new ContentHandler($html);
            $handler->insertBefore($more->render(), 0);
    
            return $handler->html();
        }
    

    Apparently, the problem is related to Class AMP_Instagram_Embed_Handler $node->getAttribute( 'data-instgrm-permalink' ) property, that is returning empty. If I change it to any string, like 'https://www.instagram.com/p/CONSk9aHq7y/' the API get the data-shortcode attribute value as expected.

    Somebody knows what could be causing this issue, and how to avoi it on my code?

    Thanks in advance.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘REST API returnig empty Instagram data-shortcode attribute’ is closed to new replies.