L
L
lPestl2016-11-11 00:32:38
Facebook
lPestl, 2016-11-11 00:32:38

How to upload a picture from a file on a computer using the facebook api?

The crux of the matter is as follows. We have a file on the hard drive C:\picture.png . How can I upload this picture to facebook using, for example, Graph API??? And I don't use facebook SDK. For example straight from the Grap API Explorer ???
For example, a picture from the Internet by URL is loaded without problems as follows:

POST graph.facebook.com
/me/photos?
url=https://appharbor.com/assets/images/stackoverflow-logo.png
&caption=Example%20caption
&access_token=<user_photos_token>

88981314ff1e40ca9dfbb1b7283abedc.png
And how to do the same, but only with the image from the hard drive?
I tried to write the path to the file in the URL and in SOURCE. Does not work? In the SDK examples, the path to the file is converted using the Curl function, but I don't know what this function does. How to do without it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Philipp, 2016-11-11
@lPestl

1. You can use curl from the command line. It is also available for Windows https://curl.haxx.se/download.html

curl \
  -F "access_token=<user_photos_token>" \
  -F "caption=This is an image file" \
  -F '[email protected]\"C:\picture.png\"' \
  "https://graph.facebook.com/v2.8/me/photos"

I don't know how Windows will escape the path to the file. Play around with escaping, if it works from the command line, then everything will be fine.
If you need it in C++, then here is an example of uploading a file via curl
. There is no difficulty in adapting it for Facebook, just add two fields with a token and an image name. The curl source is available to everyone.

R
Rou1997, 2016-11-11
@Rou1997

с помощью функции Curl , но что эта функция делает, я не знаю. Как обойтись без нее?

Для начала узнать, что делает "функция", обычно сперва стоит сделать с нею, а уже потом без нее, это так везде почти.
Готовый ответ не ждите, гораздо разумнее поискать его в Гугле, там по тем же форумам история за много лет, но и там очень мало, поэтому надо правильно формулировать запросы, ищите не "мануалы", а код, потому что "мануал" кто-то должен написать специально, а код часто выкладывают на github и т.п. просто для собственного удобства, в нем и найдете нужное.
Что вы кричите?????????????????????????????
Никто вам ничем не обязан, хоть обкричитесь. Вы же денег не платите.
Не можете, не хотите учиться искать и находить, лень изучать Curl, хочется "поскорее" а не получается - проблемы ваши и только ваши.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question