Getting file as logged in user - php

I wanted to ask if the follow is possible in PHP. Let's say there is a file on my google drive with the ID '123-abc', would it be possible to fetch it as if I was logged in to my account, without using the API?
Let's say I'm trying to download a file from 'https://drive.google.com/uc?export=download&id=123-abc', is there a way to tell the website i'm signed in by logging in with PHP? I also don't want to make the file public.

See https://developers.google.com/drive/v3/reference/files#resource for the available video metadata. Specifically:-
videoMediaMetadata object Additional metadata about video media. This
may not be available immediately upon upload.
videoMediaMetadata.width integer The width of the video in pixels.
videoMediaMetadata.height integer The height of the video in pixels.
videoMediaMetadata.durationMillis long The duration of the video in
milliseconds.
I suggest you use the "try it now" facility of https://developers.google.com/drive/v3/reference/files/get to get a file and see if the vailable meta data is what you are looking for.

Related

Get Download Link from Google Generated URL

i've been stuck on this error for over some days now.
I have this app, that helps do some youtube conversion.
I am using Youtube DL for the conversion, and after that, it generates a unique api in the form
https://r17---sn-p5qlsnl7.googlevideo.com/videoplayback?key=yt6&gir=yes&expire=1506012043&mt=1505990314&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&pl=23&dur=727.741&lmt=1502263140756131&ip=54.147.55.117&ms=au&keepalive=yes&ei=K5fDWY3TFe6S8gSCjJnwBw&mv=u&source=youtube&id=o-AMxd1cK50iCKgEiy6DllYTFo-SeXUKSQ1fpmR3vdgsVa&mn=sn-p5qlsnl7&mm=31&signature=D5A495AD2061D93871BFDB91BF3843B061E5C73A.32EB5728DA132892E6CAA88581C77352DC6AC097&requiressl=yes&clen=10878177&itag=251&ipbits=0&mime=audio%2Fwebm&ratebypass=yes
The problem now is, the link above expires after 24 hours or less, and when i click on it, it takes me to a web browser with the media version, and when i click on download, it stores the file as videoplayback which at most cases does not play on using my pc's audio/video player.
How do i download the audio from the link directly, and also give it a unique name, instead of videoplayback..
Please help//

How to save a file in a hidden location php

I have to build an application where users can download videos from a site but cannot share them. My first solution is to save these files in a hidden location on the users computer since one of the requirements is that the user should be able to watch the downloaded videos offline.
Please how do I go about saving a file in a location the user cannot see using php.
Thanks.
One solution is to generate token for each request for a video. That token would have its lifetime. Php script should be serving the content instead of giving direct access to resource to user. The script should check if the token is still active before serving the content.
It is up to you how to pass the token. The simplest way is to make it contained in uri.
No matter where you put your videos in your directory structure, you always send the data as a partial request. Once data is acquired by the user, it could be saved an reproduced.
There are techniques, however, to protect your video from direct download through curl, wget or other ways of download. And this is using a secure token and an expiration, passed as parameters. This way your video download window will be limited and generating the token manually would be pretty hard.
Chidiebere Onwunyirigbo, its a Great Question. One solution for your requirement is Steganography. It is the process of concealing your data (videos) behind other files (multimedia files like image, audio, video), in your case preferable would be Image Steganography. It is quite a old technology but new to many, you can get several ready tools/code for it on the internet which you can customize as per your need. From your side you have to provide the file that is already embedded inside the image for download. Only the tool coded for retrieval and rendering the hidden video can render your video. So, for this part all the users of your site have to first download this desktop application from your site for viewing the video. This will keep your videos safe on the users computer offline, because every user who takes the video will require the reverse steganography tool to be downloaded from your site. You can even embed secret info like users IP inside the Stego image along with the video and for each tool download, associate user computer's IP with the tool. If IP embedded inside Stego image matches with that of tool only then you allow to play else redirect application to get it registered. But the limitation would be that, the users will have to download your application and will be able to view videos only on your desktop application which will render the Steganographed video.
You cannot hide information on the user computer. Even if your process are running on a windows comp as SYSTEM user, a power user can take ownership of the files.
The only solution you have, are developing or using a known DRM system, for allowing only playing the video on a determined computer or another specifications (for example, if the program have the authentication token of some user).
At any case, you need to do two things for this:
- You need a custom application to play the video, if you want to check DRM.
- You need to recode / modify something on the video before download, for adding on them a code for allow only play on the destination computer or data used for authenticating DRM.

Are all Facebook profile pictures JPG?

I've been using the PHP GraphObject API from Facebook to get the URL of the user's profile picture, and was just wondering if ALL the Facebook profile pictures are .JPG's ...
I wanted to know this so that I know whether I need to determine the file type before saving it (using file_get_contents() and file_put_contents() etc).
Many thanks.

Cache facebook/twitter profile image

I want to let the users upload their facebook/twitter profile picture as an avatar. I insert a record with their token/secret in the DB. I've made a script that gets the user's id and displays the profile image using readfile() but I want to cache this image for 30 minutes. Is this possible with codeigniter?
Although not codeigniter specific.. On a site I created - when the user logs in with facebook, we download the file using something similar to file_get_contents.. we then store our local reference to it along with a MD5 of the image data.. This allows us to easily check whether we need to update our local store when the profile is next requested (this does require the server to re-download from facebook)
In other instances, we store the file size that facebook reports, so that we can do a HTTP HEAD request to check easily if its changed (I realise size doesn't have a direct relationship to the image changing.. however 99.9% of the time its a good indication.

Uploading Videos in Graph API

I'm putting together an application in facebook, part of which requires a user to input a bunch of information into a form, including a video and a number of text fields.
For my application, I'm using a combination of HTML, PHP, mySQL and Javascript.
I want to be able to upload the users video file to facebook using the PHP SDK in the same page as I am inserting their info into my database. I want something similiar to the photo solution here: Exception when uploading photo with Facebook Graph API. But I'm not sure what the array key should be for the video itself.
Can any give me any ideas?
My apologies,
I realized that the solution I linked to works. However, you have to give facebook time to process the video, otherwise the graph api replies false.

Categories