Answer the question
In order to leave comments, you need to log in
How to pass a string like (uid=%{%{Stripped-User-Name}":-%"{User-Name}}) to template?
How to pass a string like (uid=%{%{Stripped-User-Name}":-%"{User-Name}}) to template?
Answer the question
In order to leave comments, you need to log in
1) First, create an application. You can do this here https://developers.facebook.com
Important points: in the settings you need to specify an email address and activate the application (app review section)
2) You need to get a key to work with api. You go here https://developers.facebook.com/tools/explorer , in the upper right corner click Get Token -> Get Page Access Token, give permission to request access rights. Click Get Token again and select your group, then click Request publish_pages and agree again. Here we got a temporary key. You need to exchange it for a permanent one (well, as a permanent one .. it will be valid for 60 days, then you will need to receive it again).
You execute such a request (in the same application)
What is in square brackets, of course, you substitute your own. You take the token from the "access token" field. You execute the request, the response will be your token. Hooray.
Now, as for programming:
1) You take the Facebook SDK https://github.com/facebook/facebook-php-sdk-v4/ (of course, it's better to install it through the composer, but if you have no idea "what it is and how to work with it ", then just download and enable the autoloader, it should work.
2) Posting itself.
$app_id = ''; // ид приложения. берешь в настройках приложения (или копируешь с адресной строки)
$app_secret = ''; // ключ приложения. берешь в настройках приложения
$access_token = ''; // токен, который мы получили
$page_id = ''; // id группы
$fb = new Facebook\Facebook(array(
'app_id' => $app_id,
'app_secret' => $app_secret,
'default_graph_version' => 'v2.2',
));
$fb->setDefaultAccessToken($access_token);
// а тут мы непосредственно постим запись на стену.
// в этом примере запись представляет собой картинку + текст
$data = [
'message' => 'Текст',
'source' => $fb->fileToUpload('/полный/путь/к/картинке'),
];
$batch = [
'photo' => $fb->request('POST', "/{$page_id}/photos", $data),
];
$responses = $fb->sendBatchRequest($batch);
vista1x , the answer is clear, thanks :)
a newbie in api fb is a great start, the only place where he really explained where to get a token +100500
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question