Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7745127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:56:08+00:00 2026-06-01T09:56:08+00:00

I am really struggling with the facebook api. A have created a app, an

  • 0

I am really struggling with the facebook api. A have created a app, an object an action, and I want to test to publish in my stream, (I know the public publishing has to be authorised by facebook but as an adminsitrator of my app, I am allowed to test it). But it doesn’t wor. Here’s the script :

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
      xmlns:fb="https://www.facebook.com/2008/fbml"> 
    <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# mehdientest:http://ogp.me/ns/fb/mehdientest#">
        <title>OG Tutorial App</title>
        <meta property="fb:app_id"      content="312683425452812" /> 
        <meta property="og:type"        content="mehdientest:Campain" /> 
        <meta property="og:url"         content="http://www.example.com/pumpkinpie.html" /> 
        <meta property="og:title"       content="Sample Campain" /> 
        <meta property="og:description" content="Some Arbitrary String" /> 
        <meta property="og:image"       content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
    </head>
    <body>
        <div id="fb-root"></div>
        <script>
            window.fbAsyncInit = function() {
                FB.init({
                    appId      : '312683425452812', // App ID
                    status     : true, // check login status
                    cookie     : true, // enable cookies to allow the server to access the session
                    xfbml      : true  // parse XFBML
                });
            };

            (function(d){
                var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                js = d.createElement('script'); js.id = id; js.async = true;
                js.src = "//connect.facebook.net/en_US/all.js";
                d.getElementsByTagName('head')[0].appendChild(js);
            }(document));

            FB.Event.subscribe('auth.login', function(response) {
                // do something with response
                login();
            });

            FB.Event.subscribe('auth.logout', function(response) {
                // do something with response
                logout();
            });

            FB.getLoginStatus(function(response) {
                if (response.session) {
                    // logged in and connected user, someone you know
                    login();
                }
            });

            function login() {
                FB.login(function(response) {
                    if (response.authResponse) {
                        FB.api('/me', function(response) {
                            alert('Good to see you, ' + response.name + '.');
                        });
                    } else {
                        console.log('User cancelled login or did not fully authorize.');
                    }
                });
            }

            function publish() {
                FB.api('/me/mehdientest:Create?Campain=http://www.example.com/pumpkinpie.html', 'post', function(response) {
                    if (!response || response.error) {
                        alert('msg');
                    }
                });
            }         

            function logout(){ 
                FB.logout(function(response){});
            }
        </script>
        <h3>Example</h3>
        <p>
            <img title="Example" src="" width="550"/>
            <input type="button" value="Logout" onclick="logout();"></input>
            <input type="button" value="Login" onclick="login();"></input>
            <input type="button" value="Publish" onclick="publish();"></input>
            <div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1"></div>
        </p>
    </body>
</html>

I have even tried to call the publish() function in the head area, but this doesn’t work also.

Does anybody has an idea ?

Best,
Newben

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:56:10+00:00Added an answer on June 1, 2026 at 9:56 am

    Saying “it does not work” is not enough, you should always write what happens so that it will be easier to help you.

    In any case, your code was a mess, what’s the point of calling FB.login when the user is already logged in?

    Here’s a modified version of your code, I haven’t tested it but it should point you in the right direction.
    After you play with it a bit, and if it’s still not working, please come back and explain what you get.

    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
          xmlns:fb="https://www.facebook.com/2008/fbml"> 
        <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# mehdientest:http://ogp.me/ns/fb/mehdientest#">
            <title>OG Tutorial App</title>
            <meta property="fb:app_id"      content="312683425452812" /> 
            <meta property="og:type"        content="mehdientest:Campain" /> 
            <meta property="og:url"         content="http://www.example.com/pumpkinpie.html" /> 
            <meta property="og:title"       content="Sample Campain" /> 
            <meta property="og:description" content="Some Arbitrary String" /> 
            <meta property="og:image"       content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
        </head>
        <body>
            <div id="fb-root"></div>
            <script>
                window.fbAsyncInit = function() {
                    FB.init({
                        appId      : '312683425452812', // App ID
                        status     : true, // check login status
                        cookie     : true, // enable cookies to allow the server to access the session
                        xfbml      : true  // parse XFBML
                    });
                };
    
                (function(d){
                    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                    js = d.createElement('script'); js.id = id; js.async = true;
                    js.src = "//connect.facebook.net/en_US/all.js";
                    d.getElementsByTagName('head')[0].appendChild(js);
                }(document));
    
                FB.Event.subscribe('auth.login', function(response) {
                    FB.api('/me', function(response2) {
                        alert('Good to see you, ' + response2.name + '.');
                    });
                });
    
                FB.Event.subscribe('auth.logout', function(response) {
                    alert("ba bye");
                    document.getElementById("publish").disabled = "disabled";
                });
    
                function loggedin() {
                    document.getElementById("publish").disabled = false;
                }
    
                function publish() {
                    FB.api('/me/mehdientest:Create?Campain=http://www.example.com/pumpkinpie.html', 'post', function(response) {
                        if (!response || response.error) {
                            alert('msg');
                        }
                    });
                }
            </script>
            <h3>Example</h3>
            <p>
                <img title="Example" src="" width="550"/>
                <input type="button" value="Logout" onclick="logout();"></input>
                <input type="button" value="Login" onclick="login();"></input>
                <input type="button" id="publish" value="Publish" onclick="publish();" disabled="disabled"></input>
                <div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1"></div>
            </p>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm really struggling to make facebook connection working for my system. What I want
I am really struggling with linking menus together. The app I want to create
I am really struggling with this and I have no idea why. I want
I am really struggling with using the SqlLite in my App; I have set
im really struggling to find clear documentation on the following subject. I have created
I'm really struggling with a part of layout in my app. I have a
OK i am really struggling with this! I know had to add an image
I'm really struggling with with, and I know how easy it is but I'm
I am really struggling to understand tail recursion in Erlang. I have the following
I am really struggling with this one. I have Google'd this and tried most

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.