pull upload issue (upload from server url) - Vimeo API Php - php

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?

Related

YouTube API v3 Video Upload Path using PHP and form

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);
}
}

How to create file pdf file in google drive sdk using php

I am creating a pdf file using google drive sdk but I got an error when the file is created.. I cant download the file.
this is my php code in creating the pdf file:
$subcontent = "<h1>Hello World</h1><p>text here of some</p>";
$file = new Google_DriveFile();
$file->setTitle( $fileName );
$file->setDescription( $description );
$mkFile = $this->_service->files->insert($file, array('data' => $subcontent, 'mimeType' => 'application/pdf'));
the file is cannot be download or print..
the file also have an error displayed on the bottom saying
Opps! There was a problem loading more pages
can anyone help me in my case? I have been working on it in a week.. Thanks in advance, any help will be appreciated..
You seem to have made an assumption that Drive will convert your HTML file into a PDF file. It won't.
What you can do is ask Drive to convert your HTML to a Google doc, and then export that doc as PDF. Change your mime-type to text/html and add convert=true (see the library docs for how to do this).

uploading image file in dropbox using dropbox api in php

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.

Google Drive SDK (PHP Client Library) - Upload file but unreadable on the Google Drive UI

Here is my code to upload a file:
private function addFile(File $file, $folderProject, User $user) {
$fileToUpload = new Google_DriveFile();
$fileToUpload->setTitle($file->getName());
//set mime type
$fileToUpload->setMimeType($file->getMimeType());
//build parent and set id
$parent = new Google_ParentReference();
$parent->setId($folderProject->getId());
//set parent to file
$fileToUpload->setParents(array($parent));
$data = file_get_contents($file->getPath());
$createdFile = $this->service->files->insert($fileToUpload, array(
'data' => $data,
'mimeType' => $file->getMimeType(),
));
}
When I upload for example a docx using this PHP code the file append to be unreadable on the Google Drive website (it shows up the XML structure of the docx) and it is showing up like this in my Google Drive folder:
And when i try to upload a docx directly through Google Drive UI it showing up like this (what i want):
I'm pretty sure that the problem is coming from the fact the Google
Drive UI tries to open the file in a different way because i uploaded
it through my app, but i don't want that :)
(i have the same problem with other kind of files)
I tried to set the parameter 'convert' = true in the array but then i got this error during the upload:
..convert=true&uploadType=multipart&key=AI39si49a86oqv9fhb9yzXp7FCWL-cSqwFiClHZ‌​qS3Y3r9Hw8ujtSNlZEWZyFKBp_id7LUyFaZTJ97pMeb0XqHznycK7JJ9o_Q:
(500) Internal Error
Documentation: https://developers.google.com/drive/v2/reference/files/insert
=> But anyway i don't think to convert is the right solution, i just want to be able to see the content as if i uploaded the file through the Google Drive UI
If i open the docx from my Google Drive Sync folders and I edit and save it, I will be able to see it through the Google Drive UI (showing with the W logo)
I also getting the same problem.
But the difference is that , I am uploading pdf and able to view pdf in google drive UI.
I need to automatically convert it to google doc format by api code after adding new pdf.
If I change $mimeType = 'application/vnd.google-apps.document'; then got below error
https://www.googleapis.com/upload/drive/v2/files?convert=true&uploadType=multipart: (400) Bad Request
if I add optional parameter
$createdFile = $service->files->insert($file, array(
'data' => $data,
'mimeType' => $mimeType,
'convert' => TRUE
));
Then no change , only pdf upload no conversion takes place.
do u have any suggestion , where I need to exactly add for convert parameter ?

How do I directly upload a file stream to Flickr using a CURL POST?

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.

Categories