如何关闭墙上的Facebook帖子的弹出窗口

时间:2012-02-21 05:20:25

标签: facebook

我想使用fb API发布在墙上,当我发布消息时,在共享后,link打开并弹出窗口保持打开状态。 代码是

function writeOnWall()
  { 
    FB.init({ 
        appId:'292656140795961', 
        xfbml:true 
     });

     FB.ui({ 
     method: 'feed', 
     name: 'First Application'
     });
  }

2 个答案:

答案 0 :(得分:1)

以下简单的JavaScript示例演示了如何使用JavaScript SDK中的FB.ui方法来使用Feed对话框

FB.init({appId:“YOUR_APP_ID”,状态:true,cookie:true});

  function postToFeed() {

    // calling the API ...
    var obj = {
     method: 'feed', 
     name: 'First Application'
    };

    function callback(response) {
      alert("Post ID: " + response['post_id']);
    }

    FB.ui(obj, callback);
  }

答案 1 :(得分:0)

您可以使用以下代码发布到Facebook墙上,只需使用正确的参数调用该函数

试试这个,

<?php


    function doWallPost($postName='',$postMessage='',$postLink='',$postCaption='',$postDescription='')
    {
    $FB_APP_ID='xxxxxxxxxxxxxxxxxxxxxxxx';
    $FB_APP_SECRET='xxxxxxxxxxxxxxxxxxxxxxxxxxx';

    $APP_RETURN_URL=((substr($_SERVER['SERVER_PROTOCOL'],0,4)=="HTTP")?"http://":"https://").$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];

    $code = $_REQUEST["code"];

    if(empty($code)) 
    {
        $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=".$FB_APP_ID."&redirect_uri=".$APP_RETURN_URL."&scope=publish_stream";                  
        header("Location:$dialog_url");
    }

    $token_url = "https://graph.facebook.com/oauth/access_token?client_id=".$FB_APP_ID."&redirect_uri=".urlencode($APP_RETURN_URL)."&client_secret=".$FB_APP_SECRET."&code=".$code;
    $access_token = file_get_contents($token_url);

    $param1=explode("&",$access_token);
    $param2=explode("=",$param1[0]);
    $FB_ACCESS_TOKEN=$param2[1];


    $url = "https://graph.facebook.com/me/feed";
    $attachment =  array(   'access_token'  => $FB_ACCESS_TOKEN,                        
                    'name'          => $postName,
                    'link'          => $postLink,
                    'description'   => $postDescription,
                    'message'       => $postMessage,
                    'caption'       => $postCaption,
                );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,2);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
    $result=curl_exec($ch);
    header('Content-type:text/html');
    curl_close($ch);

    return $result
    }







    ?>