'Facebook Api Exception : Trying to upload video on facebook using graph api. its in 3 steps process

Step 1 is completed successfully.

In Step2 i am getting error .

[error] => Array
                (
                    [message] => Service temporarily unavailable
                    [type] => OAuthException
                    [is_transient] => 1
                    [code] => 2
                    [error_subcode] => 1363030
                    [error_user_title] => Video Upload Time Out
                    [error_user_msg] => Your video upload timed out before it could be completed. This is probably because of a slow network connection or because the video you're trying to upload is too large. Please try again.
                    [fbtrace_id] => A8p/+Nw29+5
                )

Please help.



Solution 1:[1]

Your file size is too big try using resumable, chunked upload for your video. For example, to upload upload a big file the_sample_file.mp4, which is 152043520 bytes. The first request initializes an upload session and tells the server the video size:

  curl \
  -X POST \
  "https://graph-video.facebook.com/v2.3/1533641336884006/videos"  \
  -F "access_token=XXXXXXXXX" \
  -F "upload_phase=start" \
  -F "file_size=152043520"

The response from server specifies the first chunk to upload:

{"upload_session_id":"1564747013773438","video_id":"1564747010440105","start_offset":"0","end_offset":"52428800"}

Here the server wants you to upload [0, 52428800] part of the_sample_fle.mp4. To do this, you would need to slice the file to chunks according to the start and end offsets, and send those chunks with transfer requests.

Once you have chunks ready to upload with the right start_offset and end_offset you can make a transfer request to upload the chunk, and get the offset for the next chunk.

You can split the video with the UNIX command split -b{X}m {filename} this will split {filename} into multiple parts which are X MB each.

You should be able to find details on facebook Api guide as well

Solution 2:[2]

I tried the resumable method Jaya said but It upload only the first chunk. but program upload all the chunks and exit the code without any error

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jaya
Solution 2 Dark Heart