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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:56:31+00:00 2026-06-03T13:56:31+00:00

I have a script to post to facebook but I’m having problems with how

  • 0

I have a script to post to facebook but I’m having problems with how the data is posted on facebook.

Since it may help others here is the full code

<?php
require 'facebook.php';
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 0;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = 0;

$pageId   = "XXXXXXXX";
$permSess = "XXXXXXXXXXXXXXXX";

$facebook = new Facebook(array(
    "appId" => "XXXXXXXXXX",
    "secret" => "XXXXXXXXXX",
    "cookie" => true
));

$page = $facebook->api("/{$pageId}");
?>

<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
    
    <head>
        <title>Post to Page Wall</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
        />
        <meta name="description" content="Post to page's wall" />
        <style>
            body {
                font-family:'Lucida Grande', Verdana, Arial, sans-serif;
                background-color: #f2f2f2;
            }
            h1 a {
                text-decoration: none;
                color: #3b5998;
            }
            h1 a:hover {
                text-decoration: underline;
            }
            form {
                border: 1px solid #eee;
                padding: 20px;
                width: 550px;
            }
            textarea, select, input, label {
                width: 500px;
                border: 1px solid #ddd;
                height: 20px;
                clear: both;
                margin: 10px;
            }
            textarea {
                height: 100px;
            }
            label {
                border: none;
                font-weight: bold;
            }
            input#submit {
                width: 100px;
            }
        </style>
    </head>
    
    <body>
        <h1>Post to Friend's Wall</h1>
        <?php if(isset($_POST[ 'submit'])) { $link=$
        _POST[ 'link']; $message=$ _POST[ 'message']; $attachment=a rray($message,$link
        ); $rest=$ facebook->api(array( "uid" => $pageId, "method" => "stream.publish", "access_token"
            => $permSess, "message" => $message )); } ?>
            <form id="Wall" name="Wall"
            method="post">
                <label for="URL">URL:</label>
                <input id="link" name="link">
                <label for="Message">Message:</label>
                <textarea id="message" name="message"></textarea>
                <input type="submit" name="submit" id="submit" value="Send!">
            </form>
    </body>

</html>

The problem:

I was using an example posted here and using that example the links submitted on the URL field where getting posted on facebook just like if you do it yourself (with the image and the description of the site) but using my code I can’t make it happen in the same way.

On " How can I post to the wall of a Facebook Fan Page using PHP and Open Graph API " some user had posted an answer but don’t work in my case.

The difference between my code and the code on the other site is the "$attachment" part of the code

<?php
if (isset($_POST['submit'])) {
    $sendTo  = $_POST['friend'];
    $link    = $_POST['link'];
    $message = $_POST['message'];
    
    // all options: https://stackoverflow.com/questions/691425/how-do-you-post-to-the-wall-on-a-facebook-page-not-profile
    $attachment = array(
        'message' => $message,
        'link' => $link
    );
    
    if ($result = $facebook->api("/$sendTo/feed/", 'post', $attachment)) {
        $feedbackMessage = "Message sent to friend $sendTo";
    } else {
        $feedbackMessage = "Oops something went wrong";
    }
}
?>

So… the question is how to properly post to a Facebook page without loss any of the benefits or the formatting using my script.

Thanks in advance

  • 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-03T13:56:33+00:00Added an answer on June 3, 2026 at 1:56 pm

    That will let you post to the facebook page and keep the format, I got What you mean !

    <?php 
    if(isset($_POST['submit'])) {
                $link = $_POST['link'];
                $message = $_POST['message'];
    
    
    
    $attachment = array(
            'access_token' => $permSess,
            'message' => $message,
            'link' => $link
    
        );
    if(    $result = $facebook->api(
            "/".$pageId."/links",
            'post',
            $attachment
        )){
                    $feedbackMessage = "Message sent to friend $sendTo";
                } else {
                    $feedbackMessage = "Oops something went wrong";
                } 
    
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,
I have PHP script and Facebook application registred but application will redirect user to
I got completely confused with gae. I have a script, that does a post
Problem background I have a post-commit script for my SVN repository which archives &
I have a PHP script that I'm calling with the .post() function in jQuery.
I have a PHP script on a server <?php // retrieve POST vars $comment
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
In a php-script i have a form, method is post, action-attribute is empty, which
I have this small PHP script that takes a POST variable and writes it
I am attempting to post form data to my app using Facebook. My form

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.