을 할 수있는 간단한 PHP 스크립트를 찾을 수이 코드가 필요합니다 .
.share-button {
font-family: sans-serif;
display: inline-block;
padding: 7px 10px;
border: 1px solid #EEE;
border-radius: 3px;
background-color: #FAFAFA;
color: #656565;
text-decoration: none;
}
.share-button:hover {
border: 1px solid #999;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
}
.share-button span {
display: inline-block;
margin-right: 10px;
color: red;
}
<a class="share-button" href="http://www.facebook.com/sharer/sharer.php?u=<?php echo get_permalink();?>&t=<?=urlencode(get_the_title());?>" target="_blank"><span id="share-facebook">0</span>Facebook</a>
<a class="share-button" href="http://www.twitter.com/intent/tweet?url=<?php echo get_permalink();?>&text=<?=urlencode(get_the_title());?>" target="_blank"><span id="share-twitter">0</span>Twitter</a>
<a class="share-button" href="http://plus.google.com/share?url=<?php echo get_permalink();?>" target="_blank"><span id="share-gplus">0</span>Google Plus</a>
카운트 공유 페이지를 참조하십시오
, 당신은 API 키가 필요하고이 논의에 점유율을 얻는 방법을 참조 더 ... 등 # 공유 페이스 북과 같은 각으로 수익을 삽입 Getting the Facebook like/share count for a given URL
API 키가 있으면 요청을하고 공유 페이지 번호를 얻습니다. 정보가있는 개체가 있으면 div에 다음과 같이 추가합니다.
트위터와 Google 플러스도 마찬가지입니다.
코드에서 액세스 토큰을 노출해야하므로 JS를 통해 클라이언트 측에서 현재 수를 요청해서는 안됩니다. 따라서 사용자가 사용자 액세스 토큰을 사용할 수 있도록 사이트에 로그인하지 않으면 서버 측에서이를 수행해야합니다. 또한, 모든 페이지로드시에이를 수행하면 안됩니다. 그러면 속도 제한을 상당히 빨리 만회 할 수 있습니다. 따라서 어떤 형태의 캐싱도 구현해야합니다. – CBroe