Identify if user has watched a video - php

I am developing an application that requires a user to view a set of videos.
How can I identify if the user has watched a particular video(complete and incomplete)?

You could embed the video on a page on your website, so you can register it that way.
You could also put a URL at the end of the video that they must follow to register they've seen the video.
I hope that the answer is "you can't" if you're talking about having watched it directly from YouTube.

You can use php's session variables, and put each video on a different webpage. Then when one video ends it redirects to another webpage and adds a value to that session. Before each page is loaded the session checks to see if the user should be on that webpage like so:
session_start();
if($_SESSION['videos']=="whatever value"){ //check to see if the session equals what value it should
$_SESSION['videos'] = 'whatever value2'; //update the value for next webpage
}
else { //if session variable doesn't equal what it should, redirect to homepage
header("Location: http://www.example.com/");
and to figure out when the video ends, just set a timer to the exact length of the video. I think you can figure that out for yourself.

Ah youtube videos. I made a YouTube Client that could do exactly what your referring to. It was a Client side URL sniffer that checked various urls for the presence of a youtube video ID. It could detect when a video was watched embedded in a site and many other places where the video could be watched.
Unfortunately, Firefox has changed their JS Engine to disallow URL sniffers, so finding if youtube videos have been watched via javascript is now out of the question. Your last option might be to authenticate the user under their youtube account and check the History. Good Luck!

Related

Change url referrer to look like comming from facebook using a redirect url

I made a pdf ebook where I embeded a link to a youtube video I uploaded.
on youtube stats, it shows that my traffic source is unknown.
I know this is hurting the seo of my video. This is why I am trying to enhance my youtube seo by making the visitors who come from my pdf looks like comming from facebook.
I know this is called faking the referral but I don't know if this can be done through this way:
1 _ user click on the link embeded in the PDF.
2 _ the user get redirected to "myscript.com".
3 _ "myscript.com" will redirect the user to youtube.
4 _ youtube stats show traffic comming from facebook.
please, if you know anything about this, help me.
This isn't possible. You can fake the referrer in your own browser, but you can't force someone else's browser to fake it.
What your solution will do is show the referrer as being your own website. That may still be better than it seemingly coming from nowhere. But, on the other hand, it may not. I'm no expert on the way that Youtube SEO works. I suspect, though, that anything which attempts to deliberately manipulate it is likely to hurt rather than help you. Let your content be its own best advert.
If you're determined to go down this route, though, an alternative solution would be to set up a Facebook page and embed the video in that. Then make the Facebook page the destination of the link in the PDF. That way, the referrer for the video really will be Facebook.
Faking a URL isn't going to enhance your SEO. If you want to track traffic from that ebook, use UTM tagging in that embedded URL.
I'm not sure if this will be reflected in your YouTube stats, but should be easy to track in Google Analytics.

How to protect an url video streaming using flumotion?

This is my scenario:
I have a localhost website that only logged in users can visit. They are stored on a mysql database.
The server side is running PHP.
Inside my website I have a video player that plays a video from a localhost flumotion video streaming server.
I want to protect my video streaming url in order to only registered users can access it. If anyone copy the video URL, it won't be able to play outside my website.
How can I do it?
EDIT: I mean "video url" as url like this: 192.168.1.221/myvideo.mp4 (my flumotion video streaming running on localhost)
This is the url that the html5 video player get. And I want to protect it from copy and paste in another browser tab. Because if i do it, I can play it without need my website.
You could check if the user is logged in, by checking if a session is set depending on how your login system works.
function is_logged_in(){
if (!isset($_SESSION['you_session_name']))//user is not logged in..
return false;
return true;
}
Then in your video page check if the user is actually logged in, and if it's not redirect him on another page:
if (!is_logged_in()) header("Location: http://redirectsite.com/page");

Redirect and hide target URL

I want to implement a website which like Youtube, these real URLs of videos has to be hidden.
When a user comes in, and the PHP webpage will authenticate the user, and redirect that user to the real URL of the video. The problem is how can I redirect URL and hide its real video URL, or other ways to prevent the real URL of videos exposed?
I don't know if I got your point, but are you looking for something like this?
$video_url = $user_is_authenticated ? $video_url : $authentication_url."?returnUrl=".$video_url;
echo "<a href='$video_url'>Video Title</a>";
This way, if the user is authenticated, you send him the real video URL, otherwise the login page would be seen instead.
If you don't want users to see the URL you can use session variables during authentication.
You want to hide the video location, I guess. Make a script to feed your video to your front.
feed.php?video=id
This will read your video file based on the video id and return it with propper headers to your frontend player.
URL bar can be hidden using JavaScript in InternetExplorer using window.open method.
And that will work only in InternetExplorer. And remaining browsers dont allow you to hide address bar, as per security issues.

Link to Facebook Fanpage Iframe

I have a problem with my fanpage. A gallery script is running a my webspace and i put it in the app also in th iframe of the Fanpage. The gallery script has get an Share button to post the photos on facebook. This part of it is running fine but when i clicked the link that was posted in Facebook i had been reffered to my page on my webspace and not to the iframe with the webpage and the photo. Is it possible to edit the link to go to this page in facebook iframe?
This is not a problem in general. You can try to redirect your website into the Facebook tab application my checking the HTTP_REFERRER and the url. You might have a look at this example
There is an URL you can try to call and see if you get redirected to the right application. Additionally, you can add app_data-parameters to the URL to identify the real target into your app.
All that can be done by the following code:
// set the target facebook page name and id to perform a forceRedirectToTab()
$tmpFbHelper
->setPageName($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.page.name'))
->setPageId($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.page.id'))
->setSecret($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.secret'));
// perform a redirect to the facebook tab application if someone opens the url out of facebook
// the facebook-linter is not affected by this :)
$tmpFbHelper->forceRedirectToTab();
// perform a deeplink if for example a special url is called or you identify some app-data
$tmpFbHelper->performDeeplink();
You will have to look at your published links into the stream so that the PHP-code finds out that you will redirect and deeplink!
I hope this ideas might help you :)

Redirect after photo upload and avoid showing graph api endpoint response - PHP SDK 3

I'm trying to build an iframe app for my work through which a user can upload a photo to their photos.
I have managed to get the photos to upload - BUT once the photo is uploaded, my app just shows the new photos ID (endpoint response) and removes everything else from the iframe (as shown in the second link below).
I want to be able to redirect to a success page or even just back to my app without showing this 'endpoint response'.
I have been using this tutorial to get me to where I am:
http://thinkdiff.net/facebook/graph-api-iframe-base-facebook-application-development-php-sdk-3-0/
and
https://developers.facebook.com/blog/post/498/
for the upload.
This is the first time I have attempted to build a Facebook app and I am really struggling, any help would really be appreciated.
Cheers,
Andy
If the question is how you can redirect a page a condition is true (i.e. the picture has been uploaded), header("Location: url") might be the answer. When using header location there are two concerns:
1) Make sure that the url you are redirecting to is absolute (including http://lalalala/llala/la)
and
2) Nothing can be outputted before your header. Consider this example:
http://php.net/manual/en/function.header.php

Categories