views:

178

answers:

1

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"&gt;
<!--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

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

A: 

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.

mattbasta
its not the case of which permission dialog to show. the thing is I am unable to even display the dialog. ANY Dialog.
amit