我正在尝试设置一个网站,以便用户可以在HTML表单中键入注释,然后在按下提交按钮后该注释将被放置在该人的墙上。
我已经设置了publish_stream权限,可以使用此处显示的方法轻松发布到流:Example
但是,如果您使用HTML表单并按提交,该页面将重新加载并完成令牌获取过程。这会导致一些重新路由,导致$ _REQUEST中的数据丢失。
有没有办法做到这一点?
感谢。
答案 0 :(得分:0)
亲爱的,你可以使用java脚本来使用它。
<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>