• I am trying to get Linkedin URN feed in a wordpress page; Actually I use:

    <p style="text-align: center;"><iframe title="Embedded post" src="https://www.linkedin.com/embed/feed/update/urn:li:share:................" class="feed_iframe" allowfullscreen="allowfullscreen"></iframe></p>

    because I am using ACF sections but I figured feeds doesn’t appear in FireFox due of some CORS restrictions. So I tried to add almost everywhere in httpd.conf, ssl.conf, htaccess the headers concerning?Access-Control-Allow-Origin?and applying to all with?*, but it didn’t worked. So I am trying to implement a different way putting a?<div id="linkedin_feeds">?inside section, calling the feed with an ajax call from scripts.js file:

    jQuery.ajax({
        dataType: "jsonp",
        headers: {  'Access-Control-Allow-Origin': '*' },
        crossDomain:true,
        url: 'https://www.linkedin.com/feed/update/urn:li:share:............',
        success: function(data){
            console.log('data: ' + data);
            jQuery('#linkedin_feeds').append(data);
        }
    });

    but it doesn’t work either in FF and Chrome (in Chrome’s Console it doesn’t expect any error but shows a warning:

    Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.linkedin.com/feed/update/urn:li:share:................?callback=jQuery..............&_=1684413141555 with MIME type text/html. See https://www.chromestatus.com/feature/........... for more details

    so I suppose even if it doesn’t appear as an error but it is blocked anyway. In Firefox it appears as blocked in Console even without any response… Do you have any suggestion about obtaining Linkedin’s post from wordpress’s page?
    To check that possible alternative retrieving Linkedin’s post via ajax I tried to create a simple html file and test it:

    <!DOCTYPE html>
    <html> 
    <head>
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    </head>
    <script type="text/javascript">
    $(document).ready(function(){
        jQuery.ajax({
           dataType: "jsonp",
           headers: {  
               'Access-Control-Allow-Origin': '*', 
               "Access-Control-Allow-Methods": "GET, POST" 
           },
           url:'https://www.linkedin.com/feed/update/urn:li:share:..',
           success: function(data){      
             console.log(data);
             jQuery('#li_feed').append(data);
           }
         });    
    });
    </script>
    <body>
        <p style="text-align: center; width: 70%">
            <div id="li_feed"></div>
        </p>
    </body>
    </html>

    but it didn’t loaded any contents inside div… maybe it is not possible to retrieve linkedin’s post via ajax?

    Thanks in advance for your help! Cheers! ??

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You’re misunderstanding CORS header application. It’s the remote source (LinkedIn) that must supply appropriate CORS headers defining allowed origins. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

    If the LinkedIn server does not allow you to be the origin, it’s their headers that would need to be changed. If the URL you’re using is supposed to be some sort of API where you should be allowed to be the origin, I recommend looking at LinkedIn’s API documentation for proper procedures.

Viewing 1 replies (of 1 total)
  • The topic ‘Retrieving Linkedin posts via Ajax is like blocked’ is closed to new replies.