I'm using the SDK found here: http://ift.tt/1iAyQLD
In addition, I'm using the process found here: http://ift.tt/1F4da0o
Here is a summary of the relevant code I have so far:
$path = '/' . $fb->getUid() . '/videos';
$params = array('upload_phase' => 'start', 'file_size' => filesize($fileName));
$startResult = (new \Facebook\FacebookRequest($this->fbSession, 'POST', $path, $params, 'v2.3'))->execute()->getGraphObject();
print_r($startResult);
$startOffset = $startResult->getProperty('start_offset');
$endOffset = $chunkSize = $startResult->getProperty('end_offset');
$uploadSessionId = $startResult->getProperty('upload_session_id');
chdir(sys_get_temp_dir());
$splitCmd = "split --bytes=$chunkSize --suffix-length=1 --numeric-suffixes $fileName {$prefix}";
exec($splitCmd);
$part = 0;
while(($startOffset < $endOffset) && ($part <= 10))
{
$curChunk = sys_get_temp_dir() . '/' . $prefix . $part;
$params = array('upload_phase' => 'transfer',
'start_offset' => $startOffset,
'upload_session_id' => $uploadSessionId,
'video_file_chunk' => '@' . $curChunk);
print_r($params);echo "\n";
$upldResult = (new \Facebook\FacebookRequest($this->fbSession, 'POST', $path, $params, 'v2.3'))->execute()->getGraphObject();
$startOffset = $upldResult->getProperty('start_offset');
$endOffset = $upldResult->getProperty('end_offset');
unlink($curChunk);
$part++;
echo "$startOffset > $endOffset\n";
}
echo "Done uploading\n";
$params = array('upload_session_id' => $uploadSessionId,
'upload_phase' => 'finish',
'title' => 'My Title',
'description' => 'My Description',
);
print_r($params); echo "\n";
$postResult = (new \Facebook\FacebookRequest($this->fbSession, 'POST', $path, $params, 'v2.3'))->execute()->getGraphObject();
print_r($postResult);
There is an exception thrown everytime on the $upldResult line: $upldResult = (new \Facebook\FacebookRequest($this->fbSession, 'POST', $path, $params, 'v2.3'))->execute()->getGraphObject();
The code is 1363041, and the message is "Invalid upload session given".
The entire output from my script is:
Facebook\GraphObject Object
(
[backingData:protected] => Array
(
[video_id] => 10205411650964653
[start_offset] => 0
[end_offset] => 1048576
[upload_session_id] => 10205411651004654
)
)
Array
(
[upload_phase] => transfer
[start_offset] => 0
[upload_session_id] => 10205411651004654
[video_file_chunk] => @/tmp/MyPrefix0
)
status: 1363041
message: (#1363041) Invalid upload session given.
I can't figure out how to fix this. I'm giving it the session id it just gave back to me to use in the resumable upload, and it's telling me that it's invalid (I think). Is anyone else using resumable upload, and how did you get it to work?
Aucun commentaire:
Enregistrer un commentaire