SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Need help understanding facebook graph API

    Hello everyone,
    I really got confused by all the APIs i found in google/facebook there seems to be graph API, rest API and whatever else they released there.
    What i also found out is that the rest API is going to be deprecated, and people need to start using the graph API
    however i find it hard to do stuff i did with the rest API using the graph API, the decomuntation is simply not understandable, i need a short and straight to the point guide on how can i post on facebook (wall,photos,videos,tags and whatever else) using the graph api.
    With the rest API i used to do it like this:
    Code:
    require_once('facebook-platform/php/facebook.php');
    try 
    {
    	$facebook = new Facebook('app ID', 'secret key');
    	$facebook->api_client->session_key = 'session key';
    	$fetch = array('friends' => array('pattern' => '.*','query' => "select uid2 from friend where uid1={$user}"));
    	$facebook->api_client->admin_setAppProperties(array('preload_fql' => json_encode($fetch)));
    	$facebook->api_client->stream_publish("some text to post",$attachment,$action_links,'pageID','pageID');
    }
    catch(Exception $e) {}
    Simple as that, nothing more nothing less, why all the new graph api guides contain crap like requiring user login in order to post, i didn't need such a thing with the above code.....
    Anyone to help?

    Thanks.

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    bump.

  3. #3
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See what you can get from here

    https://developers.facebook.com/docs.../facebook-api/

    I've never used the API, I only use FQL on it's own.

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    that still doesnt help, like i said i read their docs already + some other guides i found on google in vein.
    what does that line needed for?
    Code:
    $user_id = $facebook->getUser();
    I'm posting on facebook page on behalf of my application only, i dont need any users, any authorication or anything related to it.

    when i try some different code like this:
    Code:
    require_once("facebook.php");
    $config = array();
    $config['appId'] = 'appid';
    $config['secret'] = 'appsecret';
    $config['fileUpload'] = true;
    $facebook = new Facebook($config);
    $photo = $facebook->api('/pageID/photos','POST',array('source' => '@img.jpg', 'message' => 'test.'));
    it throws me the following error:
    Fatal error: Uncaught OAuthException: A user access token is required to request this resource. thrown in base_facebook.php on line 1106

    where do i get such a token, is that my session key? where do i put it?

    Even in my previous code i gave in first post there are 2 useless lines, the real and very simplified code is this:
    Code:
    require_once('facebook-platform/php/facebook.php');
    try 
    {
    	$facebook = new Facebook('app ID', 'secret key');
    	$facebook->api_client->session_key = 'session key';
    	$facebook->api_client->stream_publish("some text to post",$attachment,$action_links,'pageID','pageID');
    }
    catch(Exception $e) {}


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •