Upload video to facebook using graph api -
i using following code uploading videos users wall:
if( isset($_post['submitvideo']) ) { $img = $_files['source']['name']; $ret_obj = $facebook->api('/me/videos', 'post', array( 'source' => '@' . $img, 'title' => "this test", 'description' => 'test9000', 'privacy' => json_encode(array( 'value' => 'everyone' )), ) ); echo '<pre>video id: ' . $ret_obj['id'] . '</pre>'; }
the form looks this:
<form target="uploadtarget" enctype="multipart/form-data" method="post"> <input name="source" type="file"> <input type="submit" value="upload" name="submitvideo" /> </form>
my problem source of images. correct use this:
$img = $_files['source']['name'];
what should source? uploading file local computer.
edited:
if use following pattern same form , use "$post_url" action:
$post_url = "https://graph-video.facebook.com/me/videos?" . "title=" . $video_title. "&description=" . $video_desc . "&access_token=". $access_token;
it works. goes "$post_url" page shows id of uploaded file. how can use id put database?
is correct use this:
$img = $_files['source']['name'];
no, http://www.php.net/manual/en/features.file-upload.post-method.php tells you, “the original name of file on client machine.” – of course not want.
you want use name of file gets stored temporarily on server after has been uploaded server client:
$_files['userfile']['tmp_name']
the temporary filename of file in uploaded file stored on server.
if not work (f.e. temporary directory file uploads might not accessible curl [which php sdk uses internally] directly), have use move_uploaded_file
first store file in location on server.
Comments
Post a Comment