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 3691294
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:07:53+00:00 2026-05-19T04:07:53+00:00

I run a music search engine, I already use basic Facebook intergration, like the

  • 0

I run a music search engine, I already use basic Facebook intergration, like the like button, but my next aim is to create deeper intergration,

I’m aiming that when a user searches for something($q which I set as a cookie $_COOKIE[‘q’] ), a status update will appear, saying what they searched for and a link to my site.

I can allow a user login to facebook through JavaScript but I presume I would need to do it the PHP way.

I need to use PHP, as, after the user gives permission, I would like it that the user isn’t pestered again. I have the Facebook PHP SDK and have created an app on Facebook. Online tutorials haven’t really helped and i’m still on square 1, even though my PHP is okayish.

I would really appreciate if anyone gave me some guidelines/ ideas or helped code it.

Thanks in advance!
Niall

  • 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-05-19T04:07:53+00:00Added an answer on May 19, 2026 at 4:07 am

    Well What you need to do is relatively easy. I think you already have the right java script for this but I’ll add that in aswell, just incase!

    Okay! First we need to add the php script at the top of your page that gets the information if the user has logged-in to their facebook:

    define(‘FACEBOOK_APP_ID’, ‘YOUR APP ID’);
    define(‘FACEBOOK_SECRET’, ‘YOUR APP SECRET’);
    function get_facebook_cookie($app_id, $application_secret) {
    $args = array();
    parse_str(trim($COOKIE[‘fbs‘ . $app_id], ‘”‘), $args);
    ksort($args);
    $payload = ”;
    foreach ($args as $key => $value) {
    if ($key != ‘sig’) {
    $payload .= $key . ‘=’ . $value;
    }
    }
    if (md5($payload . $application_secret) != $args[‘sig’]) {
    return null;
    }
    return $args;
    }
    $fbcookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET);
    $fb_access_token = $fbcookie[‘access_token’];

    I’m presuming you know about the app ID and secret etc etc… fill those out under the define section.

    Next we need to add a couple of things into the html for the javascript login:

    FB.init({appId: ‘YOUR APP ID AGAIN’, status: true,
    cookie: true, xfbml: true});
    FB.Event.subscribe(‘auth.login’, function(response) {
    window.location.reload();
    });

    That goes into your body script.

    The next part is the facebook login button:

    ?fb:login-button perms=”publish_stream,offline_access” onlogin=”window.location.reload(true);” autologoutlink=”true”? ?/fb:login-button?

    (the question marks are the <> symbols as these conflict with the coding symbols in Stackoverflow)

    Now you may wonder about the need for offline access. That’s easy… I wonder about that too! lol I’m not 100% sure why that occurs but I think it’s my webserver (a tad odd it is) so try it without offline permissions first and if that doesn’t work then add it back in.

    So that’s all you have to do for the login aspect and posting aspect is a curl script:

    $url = “https://graph.facebook.com/me/feed”;
    $ch = curl_init();
    $attachment = array( ‘access_token’ => ” . $fb_access_token . ”,
    ‘message’ => “just searched ” . $q . ” at http://domain.com“,
    );

    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
    $result= curl_exec($ch);
    
    curl_close ($ch);
    

    So did you see what I did? don’t forget to add if statements depending on your website layout etc etc so that users don’t keep posting “i just searched at http:// domain.com” lol although that would spark that human curiosity 😉 due to no searching being done thus $q=NULL and thus it’ll still send nothing lol so maybe ad an if statement for when you have a query lol 😛 (Yes i know I added a space in the url from my ‘print’ version however stackoverflow is picky about how many url’s I can post v_v” lol).

    Please ask me if you need me to explain an other parts any further.

    Good luck and happy searching!

    Jon

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

Sidebar

Related Questions

I run a rather complex project with several independent applications. These use however a
I run into similar codes like this all the time in aspx pages: <asp:CheckBox
I want to run light music (non-stop) when user is running my application actively.
i'm building a Music PLayer and so i choose to use the library of
i have developed a music application .i have run it in ipod .It is
I run Flex Builder 3 on a mac and as my project grows -
I run a game and the running is done by hand, I have a
At run time I want to dynamically build grid columns (or another display layout)
I run my blog using Wordpress and all too recently became a big believer
We run full re-indexes every 7 days (i.e. creating the index from scratch) on

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.