Vimeo API upload set title and description - php

I am trying to upload vimeo files to a vimeo account via their PHP API.
This is my code ( we upload first to server in $[FILES][tmp_name] then we upload that file to vimeo with their php api ) -
$path = $_FILES['myfile']['tmp_name'];
$feedback = $vim->upload($path);
It works fine, just that I want it to be able to be uploaded with a title and a description.
Right now they are uploaded with the Untitled name.
There is no mention of title in their php api - https://github.com/vimeo/vimeo.php/blob/master/src/Vimeo/Vimeo.php
nor their api - https://developer.vimeo.com/api/upload/videos
Any ideas ?

Got it!
It's
$path = $_FILES['myfile']['tmp_name'];
$feedback = $vim->upload($path);
$vim->request($feedback, array(
'name' => 'ceva'
,'description' => 'alceva'
), 'PATCH');

Related

Uploaded video via DailyMotion API is not watchable by other users

I am using PHP SDK to upload videos to my DailyMotion channel, but i don't understand how this work.
I do this:
// Temporarily upload a file on Dailymotion' servers
// This does not create a video, it only offers you a public URL to work with.
$url = $api->uploadFile($videoPath);
try {
// More fields may be mandatory in order to create a video.
// Please refer to the complete API reference for a list of all the required data.
$result = $api->post(
'/me/videos',
array(
'url' => $url,
'title' => $title,
'tags' => 'video,publish,api',
'published' => true,
'is_created_for_kids' => false
)
);
print_r($result);
} catch(\Exception $e) {
die('exception: ' . $e->getMessage());
}
$api->logout();
When the video is uploaded, i keep getting a message saying "Publication in progress" for days (a week now and still getting the same message).
Although i can see/watch the video just fine if i used the account it belongs to.
I'm using 'GRANT_TYPE_PASSWORD' to upload the videos to my account.
I don't want my videos to be published in search results though, i just want my app users to be able to watch them embeded.
Any help would be highly appreciated, thanks in Advance.

Podio API image upload on item

Hoping I can get some help here. I am able to upload image files via the API, and I receive a file_id as a response, but every time I try to update an image field in an item using the id that was returned I get:
"File with mimetype application/octet-stream is not allowed, must match one of (MimeTypeMatcher('image', ('png', 'x-png', 'jpeg', 'pjpeg', 'gif', 'bmp', 'x-ms-bmp')),)
I've even added a line of code into my PHP script to pull the jpeg from file, rewrite it as a jpeg to be certain ( imagejpeg()) before uploading. Still, when I get to the point of updating the image field on the item, I get the same error. It seems all images uploaded via the API are converted to octet-stream. How do I get around this?
I'm using the Podio PHP library.
The PHP code is as follows:
$fileName = "testUpload.jpeg";
imagejpeg(imagecreatefromstring(file_get_contents($fileName)),$fileName);
$goFile = PodioFile::upload($fileName,$itemID);
$fileID = $goFile->file_id;
PodioItem::update((int)$itemID, array(
'fields' => array(
"logo" => (int)$fileID,
)
) , array(
"hook" => 0
));
Please try and replace :
$goFile = PodioFile::upload($fileName,$itemID);
with something like:
$goFile = PodioFile::upload('/path/to/example/file/example.jpg', 'example.jpg');
$fileID = $goFile->file_id;
PodioItem::update((int)$itemID, array(
'fields' => array(
"logo" => array((int)$fileID),
)
As it is described in https://developers.podio.com/examples/files#subsection_uploading
And then use $fileID as you've used. And yes, filename should have file extension as well, so it will not work with just 123123123 but should work well with 123123123.jpg

Using album image as thumbnail for open graph story

I am working on a sample application in PHP to upload a picture to facebook and use that link to create a story. All is well except for the thumbnail is not showing up. Does anyone know if it is restricted to actually use the uploaded album image as a thumbnail?Below is the code i am using
$ret_obj = $facebook->api('/me/photos', 'POST', array(
'image' => '#'.realpath($photo),
'message' => $message,));
$imgId = $ret_obj['id'];
$objectjson = json_encode(array('title'=>'Sample','url'=>'http://facebook.com/photo.php?fbid='.$imgId,'description'=>'This is a sample','image'=>'http://facebook.com/photo.php?fbid='.$imgId));
$ret_obj = $facebook->api('/me/objects/xxxx:yyyy', 'POST', array(
'object' => $objectjson));
EDIT: Forgot to mention that i am using the suggested size image and any other images other than the uploaded ones can be used as thumbnail

using regex to separate local, youtube or vimeo video

I am making a video playback website and I need to use a html5 video player to play local videos and youtube api and vimeo api to play vimeo videos. THE problem is I want to filter the link entered by the user for all 3 conditions. I tried some regex as I never used it before but was not successful. Can anyone help me giving a example showing how to separate those links for making 3 conditions
taking out the word "youtube" out of a youtube link so that i could make a condition statement
same way taking out .mp4 and .ogg extension from the local video so that it can be used to be played in a html5 video player
same way extract the word "vimeo" from a vimeo link so that I can use a vimeo api to play vimeo videos.
Can anyone help?
For example we input a youtube link
http://www.youtube.com/watch?v=example
Then how to get the word "youtube" out of this link?
And I uploaded a local video with file name
example.mp4
Then how can I get the extensoon mp4 from that?
This is adapated from a php class I wrote some times ago :
<?php
function identifyService ( $url )
{
$url = preg_replace('#\#.*$#', '', trim($url));
$services_regexp = array(
"#^\w+\.(?P<format>[a-zA-Z0-9]{2,5})#" => 'local',
'#vimeo\.com\/(?P<id>[0-9]*)[\/\?]?#i' => 'vimeo',
'#youtube\.[a-z]{0,5}/.*[\?&]?v(?:\/|=)?(?P<id>[^&]*)#i' => 'youtube'
);
foreach ( $services_regexp as $pattern => $service ) {
if ( preg_match ( $pattern, $url, $matches ) ) {
return ( $service === 'local' ) ? $matches['format'] : $service;
}
}
return false;
}
$url = "foo.ogg";
// $url = "bar.mp4";
// $url = "http://www.youtube.com/watch?v=_rqR8_mOp_A";
// $url = "http://vimeo.com/39044814";
$service = identifyService( $url );
var_dump( $service );
?>
Hope it helps.

Posting an image from one server to another? Facebook PHP Sdk

So, I have an image on a server # a location like this.... http://www.theserver.com/image/img.jpg
I have a Facebook connected website running here http://www.theOTHERserver.com/facebook/.
On the other server I plan to add some code like so..
$photo = "http://www.theserver.com/image/img.jpg";
$ret_obj = $facebook->api('/me/photos', 'POST', array(
'source' => '#' . $photo,
'message' => $message,
)
);
Does anyone know if this (the above) is going to work? There are of course many examples where the photo is stored locally...e.g.
$photo = "/img.jpg";

Categories