I use facebook graph api in my app and I faced some issues I cannot crack for a while. Unfortunately their documentation is not always clear, so I would appreciate any tips on my questions. My app is build in Next.js, but I don't think language matters here.
1.Upload video trouble.
I follow this documentation. https://developers.facebook.com/docs/video-api/guides/publishing Publish video on the page takes three steps. 1.1 Start an upload session. I use here my business app Id and my test user account for user access token
curl -i -X POST "https://graph.facebook.com/v20.0/<APP_ID>/uploads ?file_name=<FILE_NAME> &file_length=<FILE_LENGTH> &file_type=<FILE_TYPE> &access_token=<USER_ACCESS_TOKEN>"
I get successfull return
{ "id": "upload:<UPLOAD_SESSION_ID>" }
1.2. Start upload session. Same user token as in the first call and upload session Id which I received in the first response. Currently I test in Postman, so no issues yet converting video file, just file attached type video/mp4.
curl -i -X POST "https://graph.facebook.com/v20.0/upload:<UPLOAD_SESSION_ID>" --header "Authorization: OAuth <USER_ACCESS_TOKEN>" --header "file_offset: 0" --data-binary @<FILE_NAME>
Success. Receive file handle response
{ "h": "2:c2FtcGxl..." }
1.3. Publish video. And here is an error
curl -X POST \ "https://graph-video.facebook.com/v20.0/<PAGE_ID>/videos" \ -F "access_token=<PAGE_ACCESS_TOKEN>" \ -F "title=<VIDEO_TITLE>" \ -F "description=<VIDEO_DESCRIPTION>" \ -F "fbuploader_video_file_chunk=<UPLOADED_FILE_HANDLE>"
Page Id I use Page from my test user account, page token from this page. Handle - response from previous step. It end up in response:
{ "error": { "message": "(#100) Using file handle created for another user", "type": "OAuthException", "code": 100, "fbtrace_id": "AOF82skhP9OWC_yFlh_ka4q" } }
Question? For whom did they create a handle?? Which another user? I use page credentials which belong to the user, whom user_token I used in the first steps. I follow all official documentation with headers, I insert user token in the header in the second step, as required, but I always end up with this error. Any ideas what potentially can go wrong?
2.Post Page insights for analytics.
I get analytics for page following this documentation https://developers.facebook.com/docs/graph-api/reference/v20.0/insights
For example call
GET v20.0/{Page_Id}/insights?metric=page_post_engagements,page_daily_follows&period=week&since=01.09.2024&untill=30.09.2024
There are three options for most of metrics - day, week and days_28. What is not clear for me, its's how to combine it with 'since' and 'untill'? I have an interactive page, where user can dynamically select 'period', 'since' and 'untill with datePicker, It always shows different data and I'm not sure what exactly I display.. for the call
page_id/insights?metric=page_post_engagements&since=01.09.2024
I will receive data for day, week, and day_28, per day since selected date till today. But data for the same day in each of there three sections will differ. What does this data represent? Example response:
"name": "page_post_engagements", "period": "day", "values": [ { "value": 0, "end_time": "2024-09-02T07:00:00+0000" }, { "value": 0, "end_time": "2024-09-03T07:00:00+0000" }, { "value": 0, "end_time": "2024-09-04T07:00:00+0000" }, { "value": 0, "end_time": "2024-09-05T07:00:00+0000" }, { "value": 9, "end_time": "2024-09-06T07:00:00+0000" }, { "value": 4, "end_time": "2024-09-07T07:00:00+0000" }, }, { "name": "page_post_engagements", "period": "week", "values": [ { "value": 0, "end_time": "2024-09-02T07:00:00+0000" }, { "value": 0, "end_time": "2024-09-03T07:00:00+0000" }, { "value": 0, "end_time": "2024-09-04T07:00:00+0000" }, { "value": 0, "end_time": "2024-09-05T07:00:00+0000" }, { "value": 9, "end_time": "2024-09-06T07:00:00+0000" }, { "value": 13, "end_time": "2024-09-07T07:00:00+0000" }, }, { "name": "page_post_engagements", "period": "days_28", "values": [ { "value": 5, "end_time": "2024-09-02T07:00:00+0000" }, { "value": 5, "end_time": "2024-09-03T07:00:00+0000" }, { "value": 5, "end_time": "2024-09-04T07:00:00+0000" }, { "value": 5, "end_time": "2024-09-05T07:00:00+0000" }, { "value": 14, "end_time": "2024-09-06T07:00:00+0000" }, { "value": 18, "end_time": "2024-09-07T07:00:00+0000" },
Can someone explain me please? If I want, for example, display : "Your page activity this week increased/dropped for 15% compare to last week", how do I need to set my search params?
Thanks everyone for any ideas