A
A
Aleksandr Varag2016-09-15 14:44:05
PHP
Aleksandr Varag, 2016-09-15 14:44:05

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

4 answer(s)
V
vista1x, 2016-08-16
@EvgMul

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);

If the post does not go away, look at the $responses variable - it contains the server's response.
Well, the documentation should not be ignored https://developers.facebook.com/docs/php/gettingst... Here, by the way, the installation of the SDK is described in more detail

S
Sergey Baklanov, 2019-04-29
@php_cat_com

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

E
Evgeny Svirsky, 2016-08-15
@e_svirsky

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

A
Aleksandr Varag, 2016-09-16
@varag

Guys.
Please use
{% raw %}
All work perfectly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question