douke1891 2010-02-10 17:57
浏览 34

无法将Feed推送到publish_stream

i have a php based fb app. everything is running fine, but I am unable to publish stories into the user's feed. i am attaching some code for better understanding...

EDIT: The problem is I am unable to show any fbml/xfbml dialog. I can retrieve information from facebook but the fbml/xfbml just doesnt show up. Even the profile pic is not showing up.

this is the index.php page from where i want to push the feed.

<?php
    include 'fb_init.php';
?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<!--Main Stylesheet -->
<head>
    <link href="style/style-index.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="JS/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="JS/fbml_init.js"></script>

</head>

<body>

<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script>

<script type="text/javascript">
       FB.init("API_KEY", "xd_receiver.php");

     </script>

    <fb:profile-pic facebook-logo="true" size="square" uid="loggedinuser" ></fb:profile-pic>

this is the javascript fbml_init:

$(document).ready(function() {
    //<![CDATA[  
    var who;

    FB_RequireFeatures(["Api"], function(){ 
        FB.Facebook.init('API_KEY', 'xd_receiver.htm'); 
        var api = FB.Facebook.apiClient; // require user to login 
        api.requireLogin(function(exception)
        { 
            FB.FBDebug.logLevel=1; 
            FB.FBDebug.dump("Current user id is " + api.get_session().uid); 
            });

        var who = api.get_session().uid;


        var notifications;
        notifications = api.notifications_get(function(){});

        var fql_loggeduser_name, fql_loggeduser_status;
        FB.Facebook.apiClient.fql_query("select name, status, profile_update_time from user where uid = "+who,
                                     function(rows) {
                                     });

        FB.Connect.showPermissionDialog("offline_access");
        therestofthecode(who);

        });

        function therestofthecode(who){
            //alert("the uid is: "+who);
            //FB.apiClient.

        }

        function facebook_prompt_permission(permission) {
         FB.ensureInit(function() {
         FB.Connect.showPermissionDialog(permission);
         });
        }

    //]]> 
});

the above javascript function is just a prototype to test various functions. i want to ultimately use this only to push the feed. Surprisingly, the javascript is pulling user info from facebook just fine:

alt text http://img51.imageshack.us/img51/2974/screenshot20100210at112i.png

can someone tell me what is it that i am doing wrong here?

  • 写回答

1条回答 默认 最新

  • douwu8060 2010-02-10 19:51
    关注

    You're not requesting the right permission. Change this code:

    FB.Connect.showPermissionDialog("offline_access");
    

    to

    FB.Connect.showPermissionDialog("publish_stream");
    

    You can also specify a second parameter here. Give the second parameter a callback function with an argument like this:

    FB.Connect.showPermissionDialog("publish_stream", function(perms){ /* ... */ });
    

    and you can test to see if the user accepted or not (!perms will return true if the user cancelled). That way, you can avoid throwing unnecessary errors.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测