2016-07-21 5 views
0

Comment puis-je partager un post sur facebook avec l'image en utilisant addThis. J'ai écrit ce code pour partager sur facebook, twitter et mail.Comment partager un post avec image en utilisant addThis plugin dans jquery

Maintenant, je peux en mesure de poster ou de partager le contenu sans avoir l'image et je reçois comme ça (voir l'image) What i get.

S'il vous plaît aidez-moi à poster avec l'image et la légende.

J'ai ajouté mon code en violon ou même vous pouvez le voir dans cette https://jsfiddle.net/x34nnwcs/

(function() { 
 
    
 
    addthis.init(); 
 

 
    function navigatePage(e) { 
 
     var pageId = $(this).attr("id"), 
 
      $pageContent, sharingMarkup, content, 
 
      config = $.extend(true, {}, window.addthis_config), 
 
      share = $.extend(true, {}, window.addthis_share); 
 

 
     if (pageId != "pageContent") { 
 

 
      config["some_property"] = "some value"; 
 
      share.title = $(this).html(); 
 
      share.url = "http://" + pageId + ".not-a-tld"; 
 
\t \t \t \t \t \t share.photo = "http://res-5.cloudinary.com/demo/image/upload/dpr_1.0,f_auto,w_365,h_133,c_fill,g_south,o_60/group.jpg"; 
 
      $pageContent = $("#pageContent"); 
 
      sharingMarkup = $("#sharing_markup").html(); 
 
      content = $(".pageC").html(); 
 
      console.log(content); 
 
      $pageContent.html(content + sharingMarkup);    
 
      addthis.toolbox(".page_sharing_toolbox", config, share);    
 
      addthis.toolbox(".page_sharing_facebook", config, share); 
 
            
 
     } 
 
     $("#page1").click(navigatePage); 
 
    } 
 

 
    navigatePage.call(document.getElementById("pageContent")); 
 

 
}());
<div id="pageContent">  
 
    
 
     <button id="page1">Page 1</button> 
 
     <div class='pageC'> 
 
      
 
      
 
     <img src='http://res-5.cloudinary.com/demo/image/upload/dpr_1.0,f_auto,w_365,h_133,c_fill,g_south,o_60/group.jpg'/> 
 
    <p>this is a simple paragraph that is meant to be nice and easy to type which is why there will be mommas no periods or any capital letters so i guess this means that it cannot really be considered a paragraph but just a series of run on sentences this should help you get faster at typing as im trying not to use too many difficult words in it although i think that i might start making it hard by including some more difficult letters I'm typing pretty quickly so forgive me for any mistakes i think that i will not just tell you a story about the time i went to the zoo and found a monkey and a fox playing together they were so cute and i think that they were not supposed to be in the same cage but they somehow were and i loved watching them horse</p> 
 
    <p> 
 
    </div>  
 
</div> 
 

 
<script id="sharing_markup" type="text/html"> 
 
    <div class="page_sharing_facebook addthis_toolbox facebook_like"> 
 
     <a class="addthis_button_facebook_like" title="Facebook Like"></a> 
 
    </div> 
 

 
    <div class="page_sharing_toolbox addthis_toolbox addthis_default_style" style="width:290px;"> 
 
     <div class="share-icons" id="share-icons"> 
 
      <a class="addthis_button_email left" title="Email"></a>    
 
      <a class="addthis_button_facebook left" title="Facebook"></a> 
 
      <a class="addthis_button_twitter left last" title="Twitter"></a>    
 
      <a class="addthis_button_google left" title="Google"></a>    
 
     </div> 
 
    </div> 
 
</script> 
 
<script id="page1content" type="text/html"> 
 
    
 
</script> 
 

 

 

 
<!-- the async parameter has been added, query parameter style, to the hash so that things won't render until you explicitly call addthis.init() --> 
 
<script src="//s7.addthis.com/js/300/addthis_widget.js#async=1&pubid=atblog"></script> 
 
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>

Répondre

0

il vous suffit d'ajouter cette balise meta à votre <Head> sur le code HTML

<meta content="your image source" property="og:image"> 
+0

En fait, j'ai aussi essayé le méta-tag. Mais ça ne marche pas. Mon violon mis à jour - https://jsfiddle.net/x34nnwcs/3/. Si quelque chose ne va pas, laissez-moi savoir s'il vous plaît. – saravanamani

+0

votre code est vrai essayer d'effacer votre image en cache sur votre navigateur ,,, oui oui parfois l'image n'apparaît pas sur AddThis popup mais quand vous partagez post regardez votre message facebook, vous verrez l'image –