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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:55:26+00:00 2026-06-10T11:55:26+00:00

I know this error has been bitten to death over here, and I read

  • 0

I know this error has been bitten to death over here, and I read every single one to have better understanding of my problem.

But my issue is a bit different, and I wonder if anyone can give me good suggestion where to look.

I’m using wordpress + wordpress social login. This plugin authenticates user and stores name/age/email/fbID/fbProfilePic in the DB.

I’ve a little feature on my website where users registered through facebook can click and post message to the their wall.

My code looks like this:

<?php
//IF user is registered via facebook, when he clicks INTERESTED message will appear on his/her wall to spread the news

  $user = get_user_meta($current_user->ID,'Facebook',true);

    if ($user && $_GET['commentstab'] == 1 && !$_POST['delmycom']) {



      require ('Facebook/facebook.php');

      //Access details
      $facebook = new Facebook(array(
        'appId'  => 'XXX',
        'secret' => 'XXX'
        //'cookie' => true
      ));


          //try {
              $params = array(
                  'message'       =>  "Hurray! This works :)",
                  'name'          =>  "This is my title",
                  'caption'       =>  "My Caption",
                  'description'   =>  "Some Description...",
                  'link'          =>  "http://stackoverflow.com",
                  'picture'       =>  "http://i.imgur.com/VUBz8.png",
              );
              $post = $facebook->api("/$user/feed","POST",$params);

              echo "Your post was successfully posted to UID: $user";
          //} //try

          //catch (FacebookApiException $e) {
          //    $result = $e->getResult();
          //} //catch


    } //master if
?>

I read in various topics that I need publish_stream permission from user to perform this action. But since I store user info separately in my own DB, how do I get this publish stream permission? Do I need to modify wordpress plugin to store some kind of access token? and utilize this token to post to wall?

  • 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-10T11:55:27+00:00Added an answer on June 10, 2026 at 11:55 am
    1. you generate loginurl with publish_stream permission
    2. if user is not logged in with permission, you have to make sure he does
    3. redirect user to proper page

    you can do it like this,

    <?php
    include_once("facebook.php"); 
        $facebook = new Facebook(array(
          'appId'  => APP_ID,
          'secret' => APP_SECRET,
          'cookie' => true,
        ));
        $user = $facebook->getUser();
    
    
    
        if ($user) {
          try {
            // Get the user profile data you have permission to view
            $user_profile = $facebook->api('/me');
          } catch (FacebookApiException $e) {
            $user = null;
          }
        } else {
            $loginUrl = $facebook->getLoginUrl(array('scope' =>'publish_stream','redirect_uri'=>'example.com'));
          die('<script> top.location.href="'.$loginUrl.'";</script>');
        }
    
        $params = array(
                      'message'       =>  "Hurray! This works :)",
                      'name'          =>  "This is my title",
                      'caption'       =>  "My Caption",
                      'description'   =>  "Some Description...",
                      'link'          =>  "http://stackoverflow.com",
                      'picture'       =>  "http://i.imgur.com/VUBz8.png",
                  );
        $post = $facebook->api("/$user/feed","POST",$params); 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this has been asked 100 times before but every bit of code
I know this has been asked before, but nothing is working. I have signed
I know this question has been asked a million of times here at stackoverflow,
I know this question has been asked here a few times before. But i
I know this question has been asked before and I have seen a plethora
I know this question has been asked, but I can't find more than one
I know that this error has been discussed elsewhere on the web, and this
I know this question has been asked many times, but I have not been
I know this type of error has been raised many times before, but I
I know this has been addressed before but I have service that returns a

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.