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:
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.
See what you can get from here
https://developers.facebook.com/docs/reference/php/facebook-api/
I’ve never used the API, I only use FQL on it’s own.
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?
$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:
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:
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) {}