L
L
little-sea-cat2019-02-08 09:13:55
Classmates
little-sea-cat, 2019-02-08 09:13:55

Odnoklassniki Bot api. How to upload and send a file to a user?

Good day. I'm trying to send a file to the user of the classmates chat bot. I read the documentation https://apiok.ru/dev/graph_api/methods/graph.user/... but at the second step I fall down.

Uploading a file to the server
You need to upload a file to the URL obtained in the previous step.
This is done through an HTTP POST request, in the body of the request it is necessary to transfer the file that you want to download.

What should be in the body of the request, in what format is the file? Should the path to the file be absolute or local?
I ended up with a query like this:
$client->request( 'POST', $result->url, [
                'http_errors' => false,
                'headers' => [
                    'Content-Type'=> 'multipart/form-data'
                ],
                'data' => "https://test.ru/Files/".basename($file->name),
            ] );

but for all my attempts it gives HTTP Status 403 - Error reading file from request in direct mode

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question