When I'm trying to generate video download URL from localhost with PHP, it's working perfectly creating signature automatically with all videos. But when I'm shipping my code to server trying to generate download URL (for same video), it's not giving Signature with same video. Why it's happening? If the video can create signature on localhost why not on server? What actually is the wrong thing? I'm just kinda stuck.
$id = $_GET['id']; //The youtube video ID
parse_str(file_get_contents('http://www.youtube.com/get_video_info?video_id='.$id.'&sts=&asv=3&el=detailpage'),$info);
$streams = explode(',',$info['url_encoded_fmt_stream_map']);
parse_str($streams[0], $str);
echo $str['url'];
Related
I am trying to use URL as a video source to create a video post on Facebook using facebook's PHP SDK for graph API. I am trying to use uploadVideo method from the example given on https://developers.facebook.com/docs/php/howto/example_upload_video/
This method gives error
filesize(): stat failed for <URL>
It is trying to read file by using filesize() and it is not possible to use URL as the source.
The problem is while making the POST request to Facebook I have only access to the video URL and it will not be feasible to download on the local machine and post it to Facebook.
So is there other methods to use URL to post a video to Facebook?
After going through the source code for PHP SDK and how the uploadVideo method work. I found 'videoToUpload' method.
$response = $facebook->post('/'.$fb_page_id.'/videos', array(
'description' => $postData['description'],
'source' => $facebook->videoToUpload($media)
), $access_token);
This method works. But I am not sure if this is the right way to go.
Hello everyone,
I was working on a project where i need to display a video specifically from my google drive on a webpage. I don't want to manually select the video and copy its embed code, is there a way we can obtain the embed code for a video using google api (PHP preferred) ?
So that i can use this code within an iframe and display the video.
Please also suggest if there are other ways.
Thanks in advance,
You can start with Google Drive API https://developers.google.com/drive/v3/web/quickstart/php and this segment of code i hope can help you.
<?php
// New Google Client, see all settings at link in description
$client = new Google_Client();
// New Google Drive Service
$service = new Google_Service_Drive($client);
// Params with filter of MIME type for search only videos mp4 (you can change this)
$optParams = [
'q' => "mimeType='video/mp4'",
'pageSize' => 10,
'fields' => 'nextPageToken, files(id, name, webViewLink)'
];
// Get files from our request
$files = $service->files->listFiles($optParams);
// Print an iframe for each video
foreach($files->files as $file){
// Now I need to make a little detail about the next lines of code so look at [Info]
$src = str_replace('/view', '/preview', $file->webViewLink);
echo '<iframe width="500" height="200" target="_parent" src="'. $src .'"></iframe>'
}
?>
[Info]
The objects returned from $service->files->listFiles($optParams) are Google_Service_Drive_DriveFile objects and each of these have a series of properties. From v3 of Google API a properties called embedLink was removed and there isn't an alternative for this property from v2(Migrate to Google Drive API v3) so as you seen in my code i use webViewLink property that return a URL to a view of file like this:
https://drive.google.com/file/d/123456789/view
But if you use this URL inside an <iframe> the browser notice to you an error:
Refused to display 'https://drive.google.com/file/d/123456789/view' in a frame because it set 'X-Frame-Options' to 'sameorigin'.`
I'm not holding you too much on this issue and there are a lot of question about this. So we need to request a preview of file and not a view an i do that with
str_replace('/view', '/preview', $file->webViewLink);
on the URL returned by the request. Now you can use this URL in a <iframe>
i'm trying to use, Vimeo php api to play a private video using his id. I have created an account pro on vimeo, i have created a Vimeo app, i have created a token with public and private scope. The php code i use is this:
require("../Vimeo PHP path/autoload.php");
use Vimeo\Vimeo;
$client_id = "*****"; //your Vimeo number here
$client_secret = "*****"; //your Vimeo number here
$access_token = "*****"; //your Vimeo number here
$vimeo = new Vimeo($client_id, $client_secret, $access_token);
$videos = $vimeo->request("/videos/$video_id");
print_r($videos);
It works (i have take this code here).
Launching the page i can see my video inside the print_r($videos), but is still private, i see the black screen "Private video, log in to watch". Why? If i pass a client_id, a token and a secret i can't see a private video? Only users that are signed in my site can see my vimeo videos, but i wanna embed this video without force my users to create a vimeo account. How i can achive this result with private videos?
The video that is visible in that print_r is the embed video. At this step, the site respects your embed settings, followed by your on site privacy settings.
If you want to use the embed, you must set your video's privacy to "Hide from vimeo" (or disabled in the API), and then set your embed privacy to anything but "Nowhere"
If you want to use your own player, or a mobile device, you want to use one of the urls in the files key of the JSON response.
How can I access thing like the url to a banner image, the channel title, the subscriber count, and the default logo image url from youtube google's api's for Youtube?
An example of the JSON api can be found here.
How can I access this contents using PHP?
proceed in this way:
$youtube = file_get_contents("https://www.googleapis.com/youtube/v3/channels?part=snippet,brandingSettings&id=UCyoUx3RguJRgbaMo07yc_KA&key=AIzaSyCZonTWlCv92Nd93j5CuFFcqGciLIe5rx4");
$data = json_decode($youtube,true);
echo "BANNER IMAGE URL: ".$data['items'][0]['brandingSettings']['image']['bannerImageUrl']."<br>";
echo "CHANNEL TITLE: ".$data['items'][0]['brandingSettings']['channel']['title']."<br>";
and so on....
this tools its very good to view the structure of a json and extract what you need
This simple snippet should do the trick.
$myData = json_decode(file_get_contents("https://www.googleapis.com/youtube/v3/channels?part=snippet,brandingSettings&id=UCyoUx3RguJRgbaMo07yc_KA&key=AIzaSyCZonTWlCv92Nd93j5CuFFcqGciLIe5rx4"));
var_dump($myData);
I would really recommend using cURL instead of file_get_contents() for performance reasons, however that should get you started.
I wish to build an application using which I can record video (along with audio) and also audio (only audio preferably in mp3 format).
From some research I did, I found I need a client app in flash or flex, a RTMP Server (RED5 preferable as its free)
This is the code which I used to get cam working flash.
var camera:Camera = Camera.getCamera();
var video:Video = new Video();
video.attachCamera(camera);
addChild(video);
The problem is, I don't know how to send the stream to RED5.
Also, what do I need to do so that I can store the video according to the user. The website I am creating is in PHP/MySQL and need to have their own videos and audios recorded. I love the way facebook has integrated Video Recording.
Check this: http://www.actionscript.org/resources/articles/615/2/Getting-started-with-red5-server/Page2.html
It explains how to connect and use RED5 and gives you an example.
Here's the exact AS3 code for publishing video from Flash to a media server like Red5, Wowza or AMS:
//init vars
public var nc:NetConnection;
public var ns:NetStream;
//net connection to media server
nc = new NetConnection();
nc.connect("rtmp://yourmediaserver/oflaDemo/instance");
//net stream through which the recording data is sent
ns = new NetStream(nc)
//attach cam and mic to net stream
ns.attachCamera(Camera.getCamera())
ns.attachAudio(Microphone.getMicrophone())
//send the data to the media server
ns.publish("streamName","record");
For just audio comment the ns.attachAudio line .
Flash Player can't encode mp3 sound (it can decode). You'll get sound encoded with NellyMoser ASAO. Speex is also an option. See this answer for more details.
oflaDemo is a Red5 app that supports video recording that's shipped with Red5.
For a (commercial) Flash/HTML video recording solution that supports Red5 and PHP you should check out https://hdfvr.com.
Also, what do I need to do so that I can store the video according to the user.
Just execute a PHP script (from the Flash client) that saves the info in the database. You can use POST or GET to send the video data and sessions or cookies to retrieve the user data.
var video:Video;
var camera:Camera = Camera.getCamera();
camera.addEventListener(ActivityEvent.ACTIVITY, active);
video = new Video();
video.attachCamera(camera);
function active(event:Event):void
{
addChild(video);
camera.removeEventListener(ActivityEvent.ACTIVITY, active);
}