2016-07-10 2 views
0

FB에서 내 페이지를 공유하려면 다음 코드를 사용하고 있습니다. data-title, data-desc 및 data-image는 공유하지 않습니다. 대화 상자 링크가 팝업되면 FB는 앱 기본 사진 만 표시합니다. 공유되면 href가 올바르게 공유되고 앱의 기본 사진이 표시됩니다.FB 공유 SDK가 작동하지 않음 - 재고 앱 사진 만 표시

코드가 아래에 있으며 스크립트의 맨 아래에 머리글 (og 태그 포함)도 붙입니다. 거기에 갈등이 있습니까? FB가 내 PHP 태그를 읽지 못하고 있습니까?

도움을 주시면 감사하겠습니다.

HTML :

<li><div id="fb-root"></div> 
<a class="fb_share" href="<?php echo JO_Request::getInstance()->getFullUrl(); ?>" data-image="" data-title="<?php echo $this->mypage['postTitle']; ?>" data-desc="<?php echo $this->mypage['postDesc'] ? nl2br(substr($this->mypage['postDesc'], 0, 200)) . '...' : ''; ?>" data-width="450"><img src="https://www.mygoodness.com/date/myimage.png" alt="" width="20" height="20"></a></li> 

스크립트

<script type="text/javascript"> 

    window.fbAsyncInit = function() { 
     FB.init({ 
      appId: 'app id', 
      secret: 'app secret', 
      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) { 
     FB.XFBML.parse(); 
     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> 

머리 :

<head prefix="og:http://ogp.me/ns# fb:http://ogp.me/ns/fb#"> 

    <!-- Meta --> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <meta http-equiv="X-UA-Compatible" content="IE=echo,chrome=1"> 

    <meta property="fb:app_id" content="app id"> 
    <meta property="og:url" content="<?php echo JO_Request::getInstance()->getFullUrl(); ?>"> 
    <meta property="og:title" content="<?php echo $this->mypage['postTitle']; ?>"> 
    <meta property="og:image" content="<?php echo $this->baseUrl;?>myhome.png"> 
    <meta property="og:type" content="website"> 
    <meta property="og:description" content="<?php echo $this->mypage['postDesc'] ? nl2br(substr($this->mypage['postDesc'], 0, 200)) . '...' : ''; ?>"> 

</head> 
+0

스크립트 코드는 내 본성이 필요합니다. fb –

+0

@RuiCosta Thanks Rui. 당신은 - ian

+0

예, 작동하지 않으면 콘솔 로그 오류 포착 후 –

답변

0

그럼 실제로 태그가 제대로 구현, 문제는 사용자가 설정 한 이미지가 표시된다 열린 공간 그래프에 설정된 제한을 exece 공유 대화 상자에서. (최대 한도 - 8MB)

웹을 구현할 수있는 열린 그래프 태그에 대한 체코 어 설명서.
Sharing Open Graph Webmaster Guide

오픈 그래프에 대한 디버거로 링크를 검사 할 수도 있습니다. 가장 유용하다고 생각합니다. Sharing Debugger

관련 문제