0

I do lots of stuff in my javascript code for posting feed in page as m`, but how i can get permission through javascript with just one click.

This is my code.

<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p>
    <a href="javascript:;" onclick='postToFeed(); return false;'>Post to Group</a>
</p>
<p id='msg'></p>

<script> 
  FB.init({appId: "apid", status: true, cookie: true});
  function postToFeed() {
  FB.api('/page_id/feed', 'post', 
             { 
                 message     : "It's awesome ...",
                 link        : 'http://csslight.com',
                 picture     : 'http://csslight.com/application/upload/WebsitePhoto/567-grafmiville.png',
                 name        : 'Featured of the Day',
                 from: 'pageid',
                 description : 'CSS Light is a showcase for web design encouragement, submitted by web designers of all over the world. We simply accept the websites with high quality and professional touch.'
         }, 
         function(response) {
             alert(JSON.stringify(response));
         });
  }
  </script>
  </body>

Output of above script is

enter image description here

But i wan't to post as a BeCrazzy.com not Rajnish..!

simply, i want to post feed in page as a admin. please help me. :)

TheFoxLab
  • 704
  • 1
  • 5
  • 22
  • possible duplicate of [How to post to Facebook fanpage as fanpage, not user](http://facebook.stackoverflow.com/questions/8034753/how-to-post-to-facebook-fanpage-as-fanpage-not-user) – ifaour Nov 07 '12 at 13:17
  • I guess my answer above is still valid. – ifaour Nov 07 '12 at 13:18
  • Yes, you are right but i have litle bit confusion.. How to get access token using javascript api...sorry i can't get any solution. – TheFoxLab Nov 07 '12 at 14:32
  • 1
    My code in the above answer is exactly getting this! Have you tried it? read the document posted in the answer below (on how to login a user and get their `manage_pages` & `publish_stream` permission and after that my answer would 1) get a page access token 2) post as a page. – ifaour Nov 07 '12 at 15:23
  • thanxs budy, finaly i have done ...:) using php-sdk. – TheFoxLab Nov 09 '12 at 15:37
  • @Rajnish i also stopped on these step.. why can;t do in javascript... any know///??? | – K6t Jul 17 '13 at 11:59
  • @ifaour how to i get page access token ??? – K6t Jul 17 '13 at 11:59

1 Answers1

2

There is a tutorial here that shows you exactly how to do this:

https://developers.facebook.com/docs/howtos/login/login-as-page/

You will not be able to use the Facebook Javascript SDK to make the API call signed with the Page access token, you'll need to use something like jQuery.ajax() to do so.

Matthew Johnston
  • 4,409
  • 2
  • 20
  • 27
  • 1
    There is sample code in the guide, please at least attempt to follow it. – Matthew Johnston Nov 07 '12 at 11:59
  • This post helped me with the access token: http://stackoverflow.com/questions/12168452/long-lasting-fb-access-token-for-server-to-pull-fb-page-info/21927690#21927690 – Mark Jan 06 '16 at 20:25