Answer the question
In order to leave comments, you need to log in
Posting on facebook via api?
Good day. Sketched the code for auto-posting in FB
$url = 'https://www.facebook.com/dialog/oauth';
$params = array(
'client_id' => $client_id,
'redirect_uri' => $redirect_uri,
'scope' => 'manage_pages,publish_actions,publish_pages'
);
echo $link = '<p><a href="' . $url . '?' . urldecode(http_build_query($params)) . '">Аутентификация через Facebook</a></p>';
if (isset($_GET['code'])) {
$result = false;
$params = array(
'code' => $_GET['code'],
'client_id' => $client_id,
'client_secret' => $client_secret,
'redirect_uri' => $redirect_uri
);
$url = 'https://graph.facebook.com/oauth/access_token';
$access_token = null;
parse_str(file_get_contents($url . '?' . http_build_query($params)), $access_token);
pre($access_token);
if($access_token['access_token']){
$params = array(
'fields' => 'access_token',
'access_token' => $access_token['access_token']
);
$url = 'https://graph.facebook.com/v2.4/'.$page_id;
$access_token_no_limit = null;
parse_str(file_get_contents($url . '?' . http_build_query($params)), $access_token_no_limit);
pre($access_token_no_limit);
}
}
$params = array(
'access_token' => 'EAARBLjM1vYYBACrFSFTBnUA3NZCZB3HdqvZA7jeW96FKbnWlZByFCAdkK2bfUzvchmJgxNysuxPVFl1WfIpzPCpjG86MU6TwWz6zNaKZAwPq5L3aDGBhw5T9V01AvgyZCi1JZCXAg5ZARMNXEuIonLFpAZAwZC5sZCYpWteU8V9oE9cYQZDZD',
'message' => '#автопостинг\n\rHello, world! Yooohhooo :)',
'link' => 'www.caravan.su'
);
$url = 'https://graph.facebook.com/v2.8/'.$page_id.'/feed';
$post = null;
$post = json_decode(file_get_contents($url . '?' . http_build_query($params), true));
pre($post);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question