Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
556 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...