Trying to upload videos using V3 API from a form. When specifying the path to the video I'm using $videoPath = file_get_contents($_FILES["file"]["name"]); I've also tried it with out the get_file_contents and it tells me it can't find the file. I must be missing something, is there a way to upload directly from a form post without having to upload it to my server, than upload it to YouTube?
You dont allow to download video files from youtube dirrectly.
At first check path for $_FILES["file"]["name"].
I recommend to use code if you need get information about video. After you may parse data and get images/video etc.
public function getParseVideo($code = null){
$key = "your code";
if(!empty($code)){
$data = file_get_contents("https://www.googleapis.com/youtube/v3/videos? key=".$key."&part=snippet&id=".$code);
echo $json = json_decode($data);
}
}
Related
i have problem when i upload video from (form HTML)
i use Laravel FFMpeg package
this code from my controller
$file = $request->file('video'); // take video request
FFMpeg::fromDisk('public')
->open(['vid\vid_one.mp4' , $file]) // concat video here and i think there is a problem
->export()
->concatWithoutTranscoding()
->save('contacct.mp4');
You have to store that video on that point where you are using ffmpeg open function with this function:
$request->file('video')->storeAs('folderName', $request->video->getClientOriginalName(), 'diskName');
I am using vimeo PHP API, Here is the link of API: https://github.com/vimeo/vimeo.php
I am facing a issue when i upload video through web url.
The file is uploading but when i see the video on vimeo. It is saying:
Invalid file
There was a problem with the file you tried to upload.
I am using following line of code to send video to vimeo:
$lib = new Vimeo($config['client_id'], $config['client_secret'], $config['access_token']);
$response = $lib->request('/me/videos', ['type' => 'pull', 'link' => $videowebpath], 'POST');`
$videowebpath is weburl of mp4 file... like http://example.com/video/abx.mp4
If i upload the same file using upload function. It works fine on vimeo also.
Here is the code:
$uri = $lib->upload($absolutepath);
$absolutepath is absolute path of the mp4 file... like 'c:/example.com/video/abc.mp4'
I really want to make it work through pull uploads. Can any one let me know what could be the issue?
I'm using this PHP imgur API implementation. I need to be able to distinguish whether a given imgur ID is an image or an album, however, I see no way to do this with the above library.
For example, with the ID arP2Otg (from the URL https://imgur.com/gallery/arP2Otg), how would I be able to check if it's an image or an album? Otherwise, I'm unable to know which method of extraction I'm meant to use:
$album = $client->api('album')->album($albumId);
or
$image = $client->api('image')->image($imageId);
Thanks!
You can do it without using any library since their API is quite easy. Just append .json to the url and you'll get all the info about that particular link:
$data = file_get_contents('https://imgur.com/gallery/arP2Otg.json');
$obj = json_decode($data);
var_dump($obj->data->image->is_album); // will output "bool(false)"
Head over here to see all the information returned by their API.
Album URLs contain/a/ and image URLs don't.
Then, you can use strpos (assuming your mysterious id is on $theId):
if (strpos($theId, '/a/') !== false) {
$image = $client->api('image')->image($theId);
// do things with $image
} else {
$album = $client->api('album')->album($theId);
// do things with $album
}
How can I upload image files to Dropbox with the Jimscode PHP Dropbox component for CodeIgniter? It uses the add() method for uploading files. It successfully uploads all other files types (e.g. pdf) to Dropbox. But when I upload image files, it uploads empty files to Dropbox. That is of 0 bytes and unable to preview that image in Dropbox. My code:
public function add($dbpath, $filepath, array $params = array(), $root=self::DEFAULT_ROOT)
{
$dbpath = str_replace(' ', '%20', $dbpath);
$filename = rawurlencode($filepath);
$parstr = empty($params) ? '' : '&'.http_build_query($params);
$uri = "/files_put/{$root}/{$dbpath}?file={$filename}{$parstr}";
//$uri = reduce_double_slashes("/files/{$root}/{$dbpath}?file={$filename}{$parstr}");
$specialhost = 'api-content.dropbox.com';
return $this->_post_request($uri, array('file'=>'#'.$filepath), $specialhost);
}
Is there an API method I can use directly with curl and PHP?
I'm not sure what version you are using but the reduce_double_slashes line isn't commented out normally. That wouldn't cause some file types to upload and not others though. Is the failure with a single image or does it fail to upload with every image.
You can also set the DEBUG const in the library to true and have it write debug information out to your error log. That might help you figure out where the issue is happening.
I'm writing a web app that at one point allows a user to upload a photo to a flickr account (mine). I want to do this without saving the intermediate image on the server my web app is on.
What I've got so far is a page which implements phpFlickr and accepts a POST from a simple html form. I use $_FILES['file']['tmp_name'] as the path for phpFlickr to use. Here's the code:
<?php
require_once("phpFlickr.php");
$f = new phpFlickr("apikey", "secret", true);
$_SESSION['phpFlickr_auth_redirect'] = "post_upload.php";
$myPerms = $f->auth("write");
$token = $f->auth_checkToken();
$phid = $f->sync_upload($_FILES['file']['tmp_name']);
echo "Uploading Photo..." . $phid;
?>
I'm guessing that the tmp file is being lost because of the redirect that happens when $f->auth("write") is called, but I don't know. Is there a way to preserve it? Is there any way to do this without saving the file to the server?
Answer: There is No way to directly upload a file to Flickr without saving it as an intermediate file.
I've moved on to using move_uploaded_file() followed by a flickr API call, and its working perfectly.
I've also managed to get it to play nice with the excellent Jquery Uploadify, which lets me send multiple files to it in one go.