Facebook graph API post to user's wall

Posted by Lance on Stack Overflow See other posts from Stack Overflow or by Lance
Published on 2012-06-17T01:55:08Z Indexed on 2012/06/17 9:16 UTC
Read the original article Hit count: 306

Filed under:
|
|

I'm using the FB graph api to post content to the user's wall. I orginally tried using this method:

$wall_post = array(array('message' => 'predicted the',  'name' => 'predicted the'), 
                array('message' => $winning_team, 'name' => $winning_team, 'link' => 'http://www.sportannica.com/teams.php?team='.$winning_team.'&year=2012'),
                array('message' => 'to beat the', 'name' => 'to beat the',),
                array('message' => $losing_team, 'name' => $losing_team, 'link' => 'http://www.sportannica.com/teams.php?team='.$losing_team.'&year=2012'),
                array('message' => 'on '.$game_date.'', 'name' => 'on '.$game_date.''),
                array('picture' => 'http://www.sportannica.com/img/team_icons/current_season_logos/large/'.$winning_team.'.png'));

        $res = $facebook->api('/me/feed/', 'post', '$wall_post');

But, much to my surprise, you can't post multiple links to a users wall.

So, now I'm using the graph api to post content to a user's wall much like the way spotify does. So, now I've figured out that I need to create custom actions and objects with the open graph dashboard. So, I've created the "predict" action and gave it permission to edit the object "game."

So, now I have the code:

$facebook = new Facebook(array(
    'appId' => 'appID',
    'secret' => 'SECRET',
    'cookie' => true
));

$access_token = $facebook->getAccessToken();
$user = $facebook->getUser();

if($user != 0) 
{
    curl -F 'access_token='$.access_token.'' \
     -F 'away_team=New York Yankees' \
     -F 'home_team=New York Mets' \
     -F 'match=http://samples.ogp.me/413385652011237' \
        'https://graph.facebook.com/me/predict-edit-add:predict'
}

I keep getting an error reading:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

Any ideas?

© Stack Overflow or respective owner

Related posts about php

Related posts about facebook