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

  • Home
  • SEARCH
  • 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 8088443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:05:28+00:00 2026-06-05T19:05:28+00:00

I have write this code but it does work only if I am already

  • 0

I have write this code but it does work only if I am already logged in facebook, otherwise appears a popup window that require me email and password to login in facebook.

This is the code:

window.fbAsyncInit = function () {
    FB.init({
        appId: 'xxx',
        frictionlessRequests: true,
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true
    });

    function update(response) {
        if (response.authResponse) {
            FB.api('/me', function (info) {
                login(response, info);
            });

        } else {

        }
    }

    FB.getLoginStatus(update);
};
(function () {
    var e = document.createElement('script');
    e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());


function login(response, info) {
    if (response.authResponse) {
        publish();
    }
}

function publish() {
    var publish = {
        method: 'feed',
        access_token: '<?php echo $token; ?>',
        message: 'How are you ?',
        name: 'hi friends',
        caption: 'yuhuuuuuuuu',
        description: (' '),
        link: 'http://www.example.com',
        picture: 'http://cdn1.hark.com/images/000/004/514/4514/original.jpg',
        actions: [{
            name: 'Hello',
            link: 'http://www.example.com/'
        }],
        user_message_prompt: 'Share on facebook'
    };

    FB.ui(
    publish, function (response) {
        if (response && response.post_id) {
            alert('Post was published.');

        } else {
            alert('Post was not published.');
        }
    });
}
  • 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-05T19:05:29+00:00Added an answer on June 5, 2026 at 7:05 pm

    In your update method, in the blank else you should call the FB.login method:

    Calling FB.login prompts the user to authenticate your application
    using the OAuth Dialog.

    However, you can’t just do this:

    function update(response) {
        if (response.authResponse) {
            FB.api('/me', function (info) {
            login(response, info);
            });
    
        } else {
            FB.login(function(response) {
                if (response.authResponse) {
                    console.log("user is logged in!", response.authResponse);
                }
            });
        }
    }
    

    Since as it states in the documentation:

    Calling FB.login results in the JS SDK attempting to open a popup
    window. As such, this method should only be called after a user click
    event, otherwise the popup window will be blocked by most browsers.

    You’ll have to show a user a button or something that tells him to click in order to login, and then you can call the FB.login method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to write to a file, it works perfect but I
I have this code to update users data, but I can't write the for
I have this code: $coder = JSON::XS->new->utf8->pretty->allow_nonref; %perl = $coder->decode ($json); When I write
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I have this javascript line <script type=text/javascript>document.write(top.location);</script> and this code <form action=rating.php method=post> <input
Well lets say we have this c# code: public override void Write(XDRDestination destination) {
Hi I have wrote this code and it suppose to move the object every
I've wrote this simple piece of code. And I have a slight problem with
Okay, so i have this code i wrote: class Connection { public static StreamWriter
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();

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.