-1

Hey guys all the answeres i read where realy old and i think facebook updated a lot! Is somebody up to date with this problem? Knows a good tutorial or have some tips?

Kind Regards, Freddy

EDIT:

I do have a website where are news posted and i want to share them automatically on my facebook fan page. This post should contain an image and the link to my page.

fr3ddyf
  • 73
  • 8
  • Can you please elaborate your problem + anything you have tried yet – Sahil Mittal Apr 26 '14 at 09:10
  • @SahilMittal I tried out this: http://talkweb.eu/posting-to-facebook-fan-page-wall-as-an-admin-using-facebook-api/ but it doesnt work for me i think. I want to post automatically on my facebookpage without requesting for permissions. – fr3ddyf Apr 26 '14 at 09:14
  • Sorry but your question is not clear at all! There are many different possibilities. Pls make your question smaller by explaining what exactly you want to do. Also exactly what kind of posts. – Sahil Mittal Apr 26 '14 at 09:17
  • What's the problem with `\POST /me/feed`? – Sahil Mittal Apr 26 '14 at 09:30
  • See you have to explain everything related to your question. – Sahil Mittal Apr 26 '14 at 09:30
  • my problem is i dont understand the way i need to implement this into my site! – fr3ddyf Apr 26 '14 at 09:33

1 Answers1

1

I think the best approach to do this-

  1. First get the page access token of your page, then extend it to never expiring. (Permission required to get the page access token: manage_pages). See here how to get the never expiring page access token.

  2. Then simply use this token to post on the fanpage's wall as a page itself! I'm not sure if you are using any SDK (you have not mentioned in the ques), but if you dont want to use anyy SDK you can simply use curl to post on the wall-

    $url = "https://graph.facebook.com/{page-id}/feed";
    $attachment =  array(
            'access_token'  => $page_access_token,  // never-expiring token
            'message' => '{message}',
            'picture' => '{picture}',
            'link' => '{link}'
    );
    
    print_r(json_encode($attachment));
    $result = GetContentsUsingCurl($url, $attachment);
    $result = json_decode($result, TRUE);
    echo "<pre>";
    print_r($result);
    
    function GetContentsUsingCurl($url, $attachment){
       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, $url);
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
       curl_setopt($ch, CURLOPT_POST, true);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
       curl_setopt($ch, CURLOPT_HEADER, 0);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       $result = curl_exec($ch);
       curl_close ($ch);
    
       return $result;
    }
    
Community
  • 1
  • 1
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
  • ok im at work now but i dont know how to get the {short-lived-token} ... im sorry.... :O – fr3ddyf Apr 26 '14 at 13:19
  • the short-token is returned as the result of login/authentication – Sahil Mittal Apr 26 '14 at 13:29
  • when i use an accesstoken shown in graph api explorer it tells me: "Invalid response" what does this mean? – fr3ddyf Apr 26 '14 at 13:30
  • In the graph api explorer you'll have to change the app first in the drop down at top right corner, and also select the permission manage_pages – Sahil Mittal Apr 26 '14 at 13:31
  • You are doing completely wrong! Please read the steps carefully and follw them! – Sahil Mittal Apr 26 '14 at 13:35
  • LoL i thought im on the right way... i followed your link and startet with step 1.. is there a step 0? – fr3ddyf Apr 26 '14 at 13:36
  • Run step 1 in browser, not in api explorer, like this: `http://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}&fb_exchange_token={short-lived-token-from-api-explorer}` – Sahil Mittal Apr 26 '14 at 13:38
  • ok i got it it posted on the wall but it was as me and not as the page! Can you help me? – fr3ddyf Apr 26 '14 at 14:06