开发者

Use an HTML form to take data and post that on Facebook wall

I am trying to set up a site so a user can type a comment in an HTML form and that c开发者_开发问答omment will then be placed on that person's wall after pressing the submit button.

I have already set up the publish_stream permission and can publish easily to a stream using the method shown here: Example

However, if you use an HTML form and press submit, the page will reload and go through the token acquisition process. This results in some re-routing that causes the data in $_REQUEST to be lost.

Is there any way to do this?

Thanks.


Yup dear you can use it using java script.

<textarea id="status" cols="50" rows="5">Write your status here and click 'Status Set Using Legacy Api Call'</textarea>
<br />
<a href="#" onClick="setStatus(); return false;">Status Set Using JSDK Call</a>
<script type="text/javascript">
            window.fbAsyncInit = function() {
                FB.init({appId: 'Your APPI ID', status: true, cookie: true, xfbml: true});

                /* All the events registered */
                FB.Event.subscribe('auth.login', function(response) {
                    // do something with response
                    //login();
                });
                FB.Event.subscribe('auth.logout', function(response) {
                    // do something with response
                    //logout();
                });

                FB.getLoginStatus(function(response) {
                    if (response.session) {
                        // logged in and connected user, someone you know
                       // login();
                    }
                });
            };
            (function() {
                var e = document.createElement('script');
                e.type = 'text/javascript';
                e.src = document.location.protocol +
                    '//connect.facebook.net/en_US/all.js';
                e.async = true;
                document.getElementById('fb-root').appendChild(e);
            }());
function setStatus(){
                status1 = document.getElementById('status').value;
                FB.api(
                  {
                    method: 'status.set',
                    status: status1
                  },
                  function(response) {
                    if (response == 0){
                        alert('Your facebook status not updated. Give Status Update Permission.');
                    }
                    else{
                        alert('Your facebook status updated');
                    }
                  }
                );
            }
        </script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜