Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add https to get_embed_url

  • Loading branch information...
commit 0d1aeaaeab724a5bb0db2fa7c4776aeef2749d73 1 parent 3da191f
@jererc jererc authored
Showing with 30 additions and 1 deletion.
  1. +10 −1 CloudKey.php
  2. +1 −0  README.md
  3. +19 −0 test.php
View
11 CloudKey.php
@@ -60,8 +60,15 @@ public function get_embed_url($args)
$useragent = null;
$countries = null;
$referers = null;
+ $secure = false;
extract($args);
- $url = sprintf('%s/embed/%s/%s', $this->base_url, $this->user_id, $id);
+ if ($secure == true) {
+ $base_url = $this->secure_base_url;
+ }
+ else {
+ $base_url = $this->base_url;
+ }
+ $url = sprintf('%s/embed/%s/%s', $base_url, $this->user_id, $id);
return CloudKey_Helpers::sign_url($url, $this->api_key, $seclevel, $asnum, $ip, $useragent, $countries, $referers, $expires);
}
@@ -177,6 +184,8 @@ public function __construct($user_id, $api_key, $base_url = null, $cdn_url = nul
{
$this->base_url = $base_url;
}
+ $this->secure_base_url = str_replace("http:", "https:", $this->base_url);
+
if ($cdn_url !== null)
{
$this->cdn_url = $cdn_url;
View
1  README.md
@@ -66,6 +66,7 @@ Arguments:
- `id`: (required) the media id.
- `seclevel`: the security level bitmask (default is `CLOUDKEY_SECLEVEL_NONE`, see below for details).
- `expires`: the UNIX epoch expiration time (default is `time() + 7200` (2 hours from now)).
+- `secure`: `true` to get the https embed url (default is `false`).
The following arguments may be required if the `CLOUDKEY_SECLEVEL_DELEGATE` option is not specified in
the seclevel parameter, depending on the other options. This is not recommanded as it would probably
View
19 test.php
@@ -35,6 +35,7 @@ public static function suite()
$suite->addTestSuite('CloudKey_MediaMetaTest');
$suite->addTestSuite('CloudKey_MediaAssetTest');
$suite->addTestSuite('CloudKey_MediaStreamUrlTest');
+ $suite->addTestSuite('CloudKey_MediaEmbedUrlTest');
return $suite;
}
}
@@ -642,3 +643,21 @@ public function testGetStreamUrl_protocol_http()
}
}
+
+class CloudKey_MediaEmbedUrlTest extends CloudKey_MediaTestBase
+{
+ public function testGetEmbedUrl()
+ {
+ global $user_id, $api_key, $base_url;
+
+ $file = $this->cloudkey->file->upload_file('.fixtures/video.3gp');
+ $assets = array('mp4_h264_aac', 'jpeg_thumbnail_medium');
+ $media = $this->cloudkey->media->create(array('assets_names' => $assets, 'url' => $file->url));
+
+ $res = $this->cloudkey->media->get_embed_url(array('id' => $media->id));
+ $this->assertContains("http://", $res);
+
+ $res = $this->cloudkey->media->get_embed_url(array('id' => $media->id, 'secure' => true));
+ $this->assertContains("https://", $res);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.