vendredi 26 février 2016

Js SDK Facebook share image Uncaught Error: invalid version specified

I'm trying to share an image from my view to facebook through JS SDK , I'm working with laravel 5.2 and i used this script to get the js sdk file right after the < body >

> < script > 
>  window.fbAsyncInit = function() {
    FB.init({
>       appId      : 'my-app-id',
>       xfbml      : true,
>       version    : 'v2.5'
>     });   };
> 
>   (function(d, s, id){
>      var js, fjs = d.getElementsByTagName(s)[0];
>      if (d.getElementById(id)) {return;}
>      js = d.createElement(s); js.id = id;
>      js.src = "//connect.facebook.net/en_US/sdk.js";
>      fjs.parentNode.insertBefore(js, fjs);    }(document, 'script', 'facebook-
> jssdk')); 
 < /script >

and this is the a href

       <div id="fb-root"></div>
<a href="http://ift.tt/eIlFV0" data-image="Request::url()" data-title="{{$img->title}}" data-desc="{{ $img->description }}" class="fb_share">
    <img src="{{ URL::to('/') }}/{{ $img->file_path }}" alt="" width="50" height="50">
</a>

this is the script

<script>
window.fbAsyncInit = function() {
    FB.init({
        appId: 1027291920648034,
        status: true,
        cookie: true,
        xfbml: true
    });
};

(function(d, debug){var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];if   (d.getElementById(id)) {return;}js = d.createElement('script'); js.id = id; js.async = true;js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";ref.parentNode.insertBefore(js, ref);}(document, /*debug*/ false));

function postToFeed(title, desc, url, image) {
    var obj = {method: 'feed',link: url, picture: image,name: title,description: desc};
    function callback(response) {}
    FB.ui(obj, callback);
}

var fbShareBtn = document.querySelector('.fb_share');
fbShareBtn.addEventListener('click', function(e) {
    e.preventDefault();
    var title = fbShareBtn.getAttribute('data-title'),
        desc = fbShareBtn.getAttribute('data-desc'),
        url = fbShareBtn.getAttribute('href'),
        image = fbShareBtn.getAttribute('data-image');
    postToFeed(title, desc, url, image);

    return false;
});


</script>



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1TbMZkK
via IFTTT

Aucun commentaire:

Enregistrer un commentaire