Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
547 views
in Technique[技术] by (71.8m points)

facebook - Suggest Page to friends using PHP-SDK

How to implement "Suggest MY-PAGE to friends" using PHP-SDK or using Javascript SDK?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First you need the Facebook SDK bundle that contains base_facebook.php, facebook.php and fb_ca_chain_bundle.crt . You will also need fbmain.php and config.php .

Next you should have a file (e.g postToWall.php) that includes fbmain.php

<?php
include_once "fbmain.php";
?>

An example of postToWall.php file.

<html>
    <body id="my_body">
    <div id="fb-root"></div>
     <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId: '<?php echo $facebook->getAppID() ?>',
          cookie: true,
          xfbml: true,
          oauth: true
        });

        FB.Canvas.setAutoGrow();
      };

      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>

    <?php

        if ($me)
        {
            $params = array('message' => "message here",
                            'picture' => "picture hyperlink here",
                            'name'  => "name here",
                            'link' => "facebook page hyperlink here",
                            'description' => " description here"
                            );
            $status = $facebook->api('/me/feed', 'POST', $params);

            if (isset($status['id']))
            {
                        //do something
            }

        }
    ?>
    </body>
</html> 

Credits to my tutor, Mr Zen Leow


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...