2

I am trying to create a script that authenticates facebook users and posts on their wall every post they open from my site.

I have already built the authentication part. However, on the part when it automaticly posts on a user's wall, I can't get it to post the URL of the post that they are reading but only a static URL

This is My Watch.php

<?

include"func/ob_get_clean.php";
    require      'config.php';
    require_once 'inc/lib/facebook.php';
    require_once 'inc/fb.php';


$string = get_include_contents('func/db_info.php');
include("admin/settings".".php");


$surl = $_SERVER['HTTP_HOST'] ;

$getid=$_GET['v'];


if(is_numeric($getid)){
mysql_query("UPDATE videos SET views=views+1 WHERE id='$getid'");
} else {
include"func/404.php";
}
$vi=mysql_query("SELECT  * FROM videos WHERE id='$getid' LIMIT 1");
$v = mysql_fetch_object($vi);

    $vidID = "$v->videoid";
    $url = "http://gdata.youtube.com/feeds/api/videos/". $vidID;
    $doc = new DOMDocument;
    $doc->load($url);
    $title = $doc->getElementsByTagName("title")->item(0)->nodeValue;
    $des = $doc->getElementsByTagName("description")->item(0)->nodeValue;
    $key = $doc->getElementsByTagName("keywords")->item(0)->nodeValue;

//$token is the access token from the URL above
$post = array('access_token' => $token, 

'link' => 'www.mywebsitelink.com');

try{
$res = $facebook->api('/me/feed','POST',$post);
print_r($res);

} catch (Exception $e){

    echo $e->getMessage();
}


?>

<head>
<html xmlns:fb="http://ogp.me/ns/fb#">
<title><?=$title?></title>
<meta property="og:url" content="http://<?=$surl?>/watch.php?v=<?=$getid?>"/>    
<meta property="fb:app_id" content="<?=$fbappid?>"/>  
<meta property="og:title" content="<?=$title?>"/> 
<meta property="og:type" content="video" />
<meta property="og:image" content="http://img.youtube.com/vi/<?=$v->videoid?>/hqdefault.jpg"/>   
<meta property="og:description" content="<?=$des?>"/>
<meta property="og:site_name" content="YourVidz"/>

<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">
<META NAME="ROBOTS" CONTENT="INDEX"> 
<META NAME="AUTHOR" CONTENT="Menti">
<META HTTP-EQUIV="CONTENT-LANGUAGE" CONTENT="en-US">
<META NAME="COPYRIGHT" CONTENT="&copy; 2011 Galeria Shqip">
<META NAME="title" CONTENT="<?=$title?>">
<META NAME="DESCRIPTION" CONTENT="<?=$des?>">
<META NAME="KEYWORDS" CONTENT="<?=$key?>">

<link href="img/favicon.ico" rel="icon" type="image/x-icon" />
<link type="text/css" rel="stylesheet" href="css/watch.css" />




<div id="fb-root"></div>
<script>(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_GB/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

</head>
<body>
<div class="banner"><?=$banner?></script></div>

<a href="index.php"><img src="img/logo.png" border="0"></a>
<div align="center"><h3><?=$title?></h3><br>
<iframe src="vid.php?v=<?=$getid?>" height="378px" width="562px" frameborder="0"  scrolling="no"></iframe><br>

<table border="0" cellpadding="3" cellspace="0" width="562px"><tr>
<td width="400px"><?=$v->views?> Views</td>
<td>
<div class="addthis_toolbox addthis_default_style addthis_16x16_style">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_6"></a>
<a class="addthis_button_google"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
</td></tr></table>

<br>
<fb:comments href="http://<?=$surl?>/watch.php?v=<?=$getid?>" num_posts="5" width="562"  data-colorscheme="dark"></fb:comments>
</div>
<div style="display:none">    
<?=$online?>
</div>
</body>
4

0 に答える 0