解析URL到Facebook提要对话框

时间:2014-02-21 12:52:28

标签: javascript php facebook facebook-graph-api

我正在尽力将当前的网页网址解析为Facebook Feed,并且标题也是如此,我无法将其用于其中一个或另一个原因。我正在使用fb.ui js作为feed,这是我的代码:

       <div id='fb-root'></div>
  <script src='http://connect.facebook.net/en_US/all.js'></script>

<script>
    window.fbAsyncInit = function () {
        FB.init({
            appId: 24***7415376313, status: true, cookie: true,
            xfbml: false, channelUrl: 'http://www.myurl.rs/fb-channel.html'
        });
    };

function fbShare(title, fbSiteUrl, fbThumbnailUrl, fbSiteDescription) {
    var publish = {
        method: 'feed',
        name: '<?=$vacanytitle?>',
        caption: '',
        description: fbSiteDescription,
        picture: fbThumbnailUrl,
        link: '<?=$url?>',
        description: 'My current description',
      redirect_uri: 'www.myurl.rs',
        actions: [
            { name: 'MYurl', link: 'http://www.myurl.rs' }
        ],
        display: 'popup'
    };

    function callback(response) {
    }

    FB.ui(publish, callback);
}
</script>

这是我用来通过php获取当前网址的代码:

function getUrl() {
  $url  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :  'https://'.$_SERVER["SERVER_NAME"];
  $url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
  $url .= $_SERVER["REQUEST_URI"];
  return $url;
}

我的标题代码:

while ($record  = mysql_fetch_array($fetchData)){
            $vacancyid= trim($record['vacancyid']); 
            $vacancytitle= trim($record['vacancytitle']);

有没有人知道如何实施?我真的没有选择了。

0 个答案:

没有答案