简体   繁体   中英

Facebook PHP sdk is posting twice on my wall

Hey guys, I have a little problem and I don't know how can I fix it. I have this function:

public function postOnUserWall($message, $linkTitle=false, $link=false, $description=false, $picture=false) {
$attachment = array(
        'message' => $message
    );
    if ($linkTitle != false) {
        $attachment['name'] = $linkTitle;
    }
    if ($link != false) {
        $attachment['link'] = $link;
    }
    if ($description != false) {
        $attachment['description'] = $description;
    }
    if ($picture != false) {
        $attachment['picture'] = $picture;
    }

    try {
        $publishStream = $this->facebook->api("/" . $this->user . "/feed", 'post', $attachment);
        //as $_GET['publish'] is set so remove it by redirecting user to the cbase url
    } catch (FacebookApiException $e) {
        d($e);
    }
}

I am using Facebook PHP SDK 3.0.

check and make sure the no redirect is done when user accesses that page / function. some people get this problem becuase after they do the publishing, they check for certain conditions and then do a redirection again (so as to handle the authentication)

I had the same problem when i tried to post on a application fanpage. I think the problem is NOT with the programing. I solved the problem by editing the permissions of the applikation fanpage and auth dialog of the application.

  • setup application: Auth Dialog -> Default Activity Privacy:None
  • setup application page (target page): manage permissions ->
  • People can write or post content on the wall --> no
  • People can add photos and videos --> yes
  • People can add tags to photos by (Application Name) --> yes/no

Hope this helps:-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM