Howto use FB Graph to post a message on a feed (wall)

前端 未结 7 1691
谎友^
谎友^ 2020-12-23 12:50

I have created an app, and now i want to post a message on one of my friends wall with use of the new Graph API. Is this do-able?

I am already using oAuth and the Gr

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-23 13:18

    Okay, I finally solved this. Thanx to phpfour for your help :-)

    First: My connection-url looks like this (with "publish_stream"):

    $connectUrl = $this->getUrl(
      'www',
      'login.php',
      array_merge(array(
        'api_key'         => $this->getAppId(),
        'cancel_url'      => $this->getCurrentUrl(),
        'req_perms'       => 'publish_stream',
        'display'         => 'page',
        'fbconnect'       => 1,
        'next'            => $this->getCurrentUrl(),
        'return_session'  => 1,
        'session_version' => 3,
        'v'               => '1.0',
      ), $params)
    );
    

    Second; I tried to post to facebook via

    $result = $facebook->api(
        '/me/feed/',
        array('access_token' => $this->access_token, 'message' => 'Playing around with FB Graph..')
    );
    

    But the correct way to do this is include one more parameter ('post'):

    $result = $facebook->api(
        '/me/feed/',
        'post',
        array('access_token' => $this->access_token, 'message' => 'Playing around with FB Graph..')
    );
    

提交回复
热议问题