-1

Yes there's almost a hundred same question as this. i have tried the answers provided and searched on forums etc...but all didn't work for me :( . I a have an app on facebook. I want to post a link to my page's timeline. (NOT ON USER'S TIMELINE). how can i do this using php sdk? i found this post How do you post to the wall on a facebook page (not profile). it's very informative yet i still dont know excatly what to do. i also rea this post Post to Facebook Page Wall. still no help for me. this is what i have at the moment:

     require_once('libs/facebook.php');
    $facebook = new Facebook(array(
        'appId' => 'xxxxxxxxxxxxxxxxxx',
        'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    ));

    $attachment = array(
        'link' => $post_link,
        'message' => 'Another Super Story!',
        'actions' => array(
            array(
                'link' => $post_link
            )
        )
    );

    $result = $facebook->api('/me/feed/', 'post', $attachment);

i saw this code but i dont know what the number stands for

$facebook->api('/123456789/feed', 'post', array( 'access_token' => $token, 'link' => 'http://www.example.com' ));

please help me. im desperate to solve my problem. i dont know what to do. thank you in advance.

EDIT: i now have this code as i have refered to this question Facebook API: How to post to my own wall page? . but still, not working for me. anyone who could tell what i'm missing?

    $page_access_token = "2xxxxxxxxxxxx|bxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
                $result = $facebook->api("/me/accounts");
                foreach($result["data"] as $page) {
                    if($page["id"] == $page_id) {
                        //$page_access_token = $page["access_token"];
                        $page_access_token = $facebook->api("/".FB_PAGE_ID."?fields=access_token");
                        break;
                    }
                }
    $attachment = array(
    'message' => $post_msg,
    'link' => $post_link,
    'access_token' => $page_access_token,
    );
    $facebook->api("/".FB_PAGE_ID.'/feed', 'POST', $attachment);
Community
  • 1
  • 1

1 Answers1

1

Before using facebook api methods, you need get access token. May be this example will be useful for you https://github.com/facebook/facebook-php-sdk/blob/master/examples/example.php

dolzhenko
  • 86
  • 2
  • 2
  • thanks for answering. iv'e been wating for someone to answer me. i have tried that one. but it posts to the user's timeline. what i need to to is for my paga/app to post on the page itself. how can i get my page's access token? thanks for helping me further – user2978990 Nov 14 '13 at 12:41