开发者

Facebook stream.publish and outdated template bundles?

开发者 https://www.devze.com 2022-12-17 18:15 出处:网络
I haven\'t tried messing with the facebook PHP API for months. Since template bundles are apparently now defunct, how can I publish a story into my users news feed for their friends? I\'ve also alread

I haven't tried messing with the facebook PHP API for months. Since template bundles are apparently now defunct, how can I publish a story into my users news feed for their friends? I've also already requested permissions.

Edit: The issue seems to arise from requested permissions not being set for the user when They are granted.

So far I have this

$appapikey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$appsecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$facebook = new Facebook($appapikey, $appsecret);
$fb_user = $facebook->require_login();

try {
    $facebook->api_client->feed_publishUserAction();
} catch(Exception $e) { }

Edit: I've looked through the facebook "api 开发者_如何学Godocumentation" multiple times it's just not clear to me. I can't tell what's actually deprecated or not. They link to tutorials 2-3 years old!

If you have a problem with your iframe application reloading over and over and over try using

$facebook->require_frame()


Have you already looked up the topic on the facebook wiki? http://wiki.developers.facebook.com/index.php/Stream.publish

There's a nice example which should help you out. If not, you'll have to describe your problem more accurate.

EDIT: You can check and request for the permissions like this (and also request them)

function check_perms() {

    global $facebook, $uid;

    $data = $facebook->api_client->fql_query( "SELECT uid, publish_stream FROM permissions WHERE uid = " . $uid );
    if( $data[0]['publish_stream'] != true ) {
        echo '<br /><p>No \'publish_stream\' permissons found!<br />';
        echo '<fb:prompt-permission perms="publish_stream"> Allow me to publish to your wall (*click*) </fb:prompt-permission>';
        echo '<br />You\'ll have to refresh the page to continue.</p>';
        die();
    }

}


    <?php
          $message ="Your Message";
           $attachment = array( 
            'name' => 'Application Name or message', 
            'href' => 'http://apps.facebook.com/tshirtquote', 
            'description' => 'Choose/Write your T-shirt Quote, Get A Tshirt Free printed with your Favorite Quote',
            'media' => array(array('type' => 'image', 'src' => 'http://linkdoo.com/tshirtquote/images/tshirt1.JPG', 'href' => 'http://apps.facebook.com/tshirtquote/')), 
            ); 
           $action_links = array( array('text' => 'WriteYourTShirtQuote', 'href' =>   'http://apps.facebook.com/tshirtquote')); 
           $attachment = json_encode($attachment); 
           $action_links = json_encode($action_links);
           $message = json_encode($message);
      ?>
     <script>
     var attachment = <?= $attachment ?>;
     var message = <?= $message ?>;
     var action_links = <?= $action_links ?>;
     Facebook.streamPublish(message,attachment,action_links);

     </script>

Use above script , It is most easy way to publish

0

精彩评论

暂无评论...
验证码 换一张
取 消