Erencim paylaşımın için teşekkürler.
Ancak "
http://s7.addthis.com" güvenilir mi çünkü senin dosyalarına eklediğin bu adres senin site içereğini görebilecektir bu güvenlik açığı yaratabilir.
Facebook ve tw paylaşımı artık ihtiyaç olduğundan güvenli kod çalışması yapılması gerektiğine inanıyorum. O yüzden kendi kodunu yazman daha doğru bir yaklaşım olacaktır.
Son çalışmam olan
http://kocgirikulturmerkezi.com'nde hazır scriptleri kullanmak yerine kendim kodlamasını yaptığım scripti sizlerle paylaşmak isterim.
Scriptin yer yerden erişilebilmesi için api dosyasının sonuna bu fonksiyonları ekleyin böylelikle include etme ile uğraşmazsınız
include/mx_api.php dosyasının ?> hemen öncesine aşağıdaki kodu ekleyin
video paylaşımı için; facevideobutton fonksiyonunu ve diğer her şey için; facesharebutton fonksiyonlarını kullanacağız. buher iki fonksiyonda hem face hem de tw butonlları oluşturur.
//-----------------------------------------------------------------------------
function facevideobutton($params)
{
global $nukeurl, $sitename, $slogan;
// Face book paramterelerini hazırlıyoruz siz isteğinize göre değiştirin
$url = "http://".$_SERVER['HTTP_HOST'] . getenv('REQUEST_URI');
$urlx = urlencode($url);
$fb_width = 70;
$fb_height = 22;
$fbcolorscheme = "light";
$fbfontbutton = "verdana";
$fbaction = "like";
$fbshowface = "false";
$fblayout = "button";
if(empty($params['tanim']))
{
$meta = $slogan;
}
else{
$meta = strip_tags(filter_text($params['tanim']));
$meta = str_replace(array("\n", "\r", "\t", '"'), ' ', $meta);
$meta = substr($meta, 0, 300);
}
$img = $params['resim'];
if(!(strpos($img,"http") AND strpos($img, "www")))
{
if($img[0] == '/')
$img = "http://".$_SERVER['HTTP_HOST'].$img;
else
$img = "http://".$_SERVER['HTTP_HOST'].'/'.$img;
}
pmxHeader::add(' <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
<style>
spam.socialshare
{
padding-top:2px;
border: none;
Float:right;
}
</style>
<meta property="og:title" content="'.$sitename.' - ('.$params['adi'].')"/> //videonun adı
<meta property="og:description" content="'.$meta.' .."/> //Kısa açıklama
<meta property="og:type" content="video"> //Paylaşım türü
<meta property="og:image" content="'.$img.'"/> //Videonun resimi
<meta property="og:video" content="'.$params['video'].'"/> //Videonuna adresi
<meta property="og:video:height" content="'.$params['h'].'" /> //video yükseklik
<meta property="og:video:width" content="'.$params['w'].'" /> //video genişlik
<meta property="og:site_name" content="'.$sitename.'"/> //Site adı
<meta property="og:url" content="'.$url.'"/> //Sayafının adresi
<meta name="description" content="'.$slogan.'" />
<meta property="og:video:type" content="application/x-shockwave-flash">
');
$tw ='<a href="http://twitter.com/share" class="twitter-share-button"
data-count="none" data-url="'.$url.'" data-title="'.$params['adi'].'"
data-text="'.$meta.'" data-via="'.$sitename.'">Tweet</a>';
$base="<iframe src=\"http://www.facebook.com/plugins/like.php?href=".$urlx."
&header=true&layout=".$fblayout."&show_faces=".$fbshowface."
&width=".$fb_width."&action=".$fbaction."&font=".$fbfontbutton."
&colorscheme=".$fbcolorscheme."&height=".$fb_height."\"
scrolling=\"no\" frameborder=\"0\"
style=\"border:none; overflow:hidden; width:".$fb_width."px;height:".$fb_height."px;\" allowTransparency=\"true\">
</iframe>";
return "<spam class=\"socialshare\">".$tw.$base."</spam>";
}
//-----------------------------------------------------------------------------
function facesharebutton($title, $cont)
{
global $nukeurl, $sitename, $slogan;
// Face book paramterelerini hazırlıyoruz siz isteğinize göre değiştirin
$url = "http://".$_SERVER['HTTP_HOST'] . getenv('REQUEST_URI');
$urlx = urlencode($url);
$fb_width = 90;
$fb_height = 22;
$fbcolorscheme = "light";
$fbfontbutton = "verdana";
$fbaction = "like";
$fbshowface = "false";
$fblayout = "button_count";
//Kısa tanım hazırlığı 250 karakter
$meta = strip_tags(filter_text($cont));
$meta = str_replace(array("\n", "\r", "\t",'"'), ' ', $meta);
$meta = substr($meta, 0, 250);
//metin içinden resimi al
preg_match("/<img(.+?)src=[\'\"](.+?)[\'\"](.*?)>/is", $cont, $image);
if (is_array($image) && !empty($image)) {
$img = $image[2];
//resim harici bir adres ise aitse değişiklik yapma
if(!(strpos($img,"http") AND strpos($img, "www")))
{
//Resim tam adresini hazırlıyoruz
if($img[0] == '/')
$img = "http://".$_SERVER['HTTP_HOST'].$img;
else
$img = "http://".$_SERVER['HTTP_HOST'].'/'.$img;
}
pmxHeader::add(' <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
<style>
div.socialshare_fb
{
padding-right: 5px;
border: none;
Float:right;
}
</style>
<meta property="og:type" content="article"/> //Paylaşılan tür 'Makale'
<meta property="og:title" content="'.$sitename.' - ('.$title.')"/> //Makale adı
<meta property="og:site_name" content="'.$sitename.'"/> //Site adı
<meta property="og:description" content="'.$meta.' .."/> //Kısa tanım
<meta name="description" content="'.$slogan.'" /> //Site Slogan
<meta property="og:url" content="'.$url.'"/> //Makale asafasının tam adresi
<meta property="og:image" content="'.$img.'"/> //Resimin tam adresi
');
//Tweet butonunu hazırla
$tw ='<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal"
data-url="'.$url.'" data-title="'.$title.'"
data-text="'.$meta.'" data-via="'.$sitename.'">Tweet</a>';
//Face butonunu hazırla
$base="<div class=\"socialshare_fb\">$tw
<iframe src=\"http://www.facebook.com/plugins/like.php?href=".$urlx."
&header=true&layout=".$fblayout."&show_faces=".$fbshowface."
&width=".$fb_width."&action=".$fbaction."&font=".$fbfontbutton."
&colorscheme=".$fbcolorscheme."&height=".$fb_height."\"
scrolling=\"no\" frameborder=\"0\"
style=\"border:none; overflow:hidden; width:".$fb_width."px; height:".$fb_height."px;\" allowTransparency=\"true\">
</iframe></div>";
return $base;
}
//------------------------------------------------------------
Bu iki fonksiyonu değişiklik yapmadan mx_api.php sonuna ekliyin facebook paramterelerini isteğinize göre değiştirin.
Şimdide kullanalım tuşlar nerede görünecekse orada kullanacağız
modules/Content/index.php de kullanalım
130. satırda _GOBACK göreceksiniz
echo "<br><br>" . _GOBACK . "<br><br>
</p>
orayı şöyle değiştirin
echo "</p>".facesharebutton($mypage['title'], $mypage['page_header'] . $mypage['text'])."
<br><br><p align='center'>" . _GOBACK . "<br><br>
</p>
Şimdide haber paylaşımı yapalım
modules/News/article.php
Bul satır 76
themearticle($story["aid"], $story["informant"], $story["datetime"], $story["title_formated"], $story["completetext"], $story["topic"], $story["topicname"], $story["topicimage"], $story["topictext"], $story);
Değiştir
themearticle($story["aid"], $story["informant"], $story["datetime"], $story["title_formated"], $story["completetext"].facesharebutton($story["title"], $story["completetext"]), $story["topic"], $story["topicname"], $story["topicimage"], $story["topictext"], $story);
Şimdide video paylaşımı yapalım
Video Stream scripti kullandığınızı farz ediyorum
modules/Video_Stream/watch.php dosyasında değişiklik yapacağız ancak gerekli parametrelerin hazırlanması gerekir
resmi, video dosyasının adresi, kısa tanım ve boyutları
200. satırda şunu göreceksiniz
echo "</table><br /><center><a href=\"javascript:loadvidpop(".$id.",".$popheight.",".$popwidth.")\">"._PLAYINPOPUP."</a></center></td>\n";
Değiştir
$para['video'] = $url;
$para['tanim'] = $row['description'];
$para['resim'] = $row['thumbimg'];
$para['adi'] = $row['vidname'];
$para['w'] = $row['width'];
$para['h'] = $row['height'];
echo "</table><br /><center><a href=\"javascript:loadvidpop(".$id.",".$popheight.",".$popwidth.")\">"._PLAYINPOPUP."</a>".facevideobutton($para)."</center></td>\n";
Başarılar
Yaşar ismail Aktaş