0

my question is simple. How post on ticker and activity recent BUT not on the wall(timeline) with PHP. (publish an action). I have already done in javascript but I want it in php

I've test this :

$params = array(
            'message'       =>  "This post is a test",
            'name'          =>  "Titre de mon test",
            'caption'       =>  "My Caption",
            'description'   =>  "Some Description...",
            'link'          =>  "http://stackoverflow.com",
            'actions' => array('name'=>'Recipe','link'=>'url'),
            'picture'       =>  "http://i.imgur.com/VUBz8.png",
        );

        $post = $facebook->api("/$user/feed","POST",$params);

thanks.

i found EDIT :

i found

<meta property="og:title" content="My article" />
<meta property="og:type" content="namespace:recipe" />
<meta property="og:url" content="http://url/" />
<meta property="og:image" content="" />
<meta property="fb:app_id" content="apikey" />
<meta property="og:description" content="My wonderful article" />

and php

try {
        $action = array('name' => 'recipe', 'link' => 'http://url/');
        $actions = json_encode($action);
        $params = array('recipe'=>'http://url/','access_token'=>$facebook->getAccessToken(), 'actions'=> urlencode($actions));
        $out = $facebook->api('/me/namespace:cook','post',$params);
        echo "Your post was successfully posted to UID: $user";

    }
    catch (FacebookApiException $e) {
       $result = $e->getResult();
    }


}
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
  • How did you manage to do that with javascript? – Nitzan Tomer May 21 '12 at 11:18
  • FB.api( '/me/namespace:cook', 'post', { recipe: 'http://url' }, function(response) { if (!response || response.error) { alert('Error occured'); } else { alert('Cook was successful! Action ID: ' + response.id); } }); – Ludovic Le Henaff May 21 '12 at 14:05

1 Answers1

1

In order to post Activity, you need to create a Action and Object. You need to follow the instruction at http://developers.facebook.com/docs/opengraph/keyconcepts/.

The PHP and JavaScript code you have specified in your question is correct to publish actions to the user's profile, provided that you have requested the publish_actions permission from the user. The action also needs to be approved by Facebook before a user can use it.

$params = array( 'recipe'=>'http://url/' );
$out = $facebook->api( '/me/namespace:cook','post', $params );
if ( $out )
    echo "Activity posted";
else
    echo "Post was unsuccessful";
Niraj Shah
  • 15,087
  • 3
  • 41
  • 60