SoundCloud embedded

221
02 мая 2017, 08:25

How to make it embedded? Like a player, not a link

<?php
/**
 * SoundCloud.php
 *
 * @package Providers
 * @author Michael Pratt <pratt@hablarmierda.net>
 * @link   http://www.michael-pratt.com/
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Embera\Providers;
/**
 * The soundcloud.com Provider
 * @link http://soundcloud.com
 */
class SoundCloud extends \Embera\Adapters\Service
{
    /** inline {@inheritdoc} */
    protected $apiUrl = 'https://soundcloud.com/oembed?format=json';
    /** inline {@inheritdoc} */
    protected function validateUrl()
    {
        $this->url->stripLastSlash();
        $this->url->invalidPattern('soundcloud\.com/(explore|creators|groups)/?$');
        return (preg_match('~soundcloud\.com/(?:[\w\d\-_]+)~i', $this->url));
    }
}
?>

Spotify embedded example:

<?php
/**
 * Spotify.php
 *
 * @package Providers
 * @author Michael Pratt <pratt@hablarmierda.net>
 * @link   http://www.michael-pratt.com/
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Embera\Providers;
/**
 * The spotify.com Provider
 */
class Spotify extends \Embera\Adapters\Service
{
    /** inline {@inheritdoc} */
    protected $apiUrl = 'https://embed.spotify.com/oembed/';
    /** inline {@inheritdoc} */
    protected function validateUrl()
    {
        return (
            preg_match('~spotify\.com/(?:track|album)/(?:[^/]+)(?:/[^/]*)?$~i', $this->url) ||
            preg_match('~spotify\.com/user/(?:[^/]+)/playlist/(?:[^/]+)/?$~i', $this->url) ||
            preg_match('~spoti\.fi/(?:[^/]+)$~i', $this->url)
        );
    }
    /** inline {@inheritdoc} */
    protected function normalizeUrl()
    {
        $this->url->convertToHttps();
        $this->url->stripQueryString();
        $this->url->stripLastSlash();
        if (preg_match('~spotify\.com/(track|album)/([^/]+)/(?:[^/]*)$~i', $this->url, $matches)) {
            $this->url = new \Embera\Url('https://play.spotify.com/' . $matches['1'] . '/' . $matches['2']);
        }
    }
    /** inline {@inheritdoc} */
    public function fakeResponse()
    {
        if (preg_match('~spoti\.fi~i', $this->url)) {
            return array();
        }
        preg_match('~/(track|album|user)/.+~i', $this->url, $matches);
        $code = str_replace('/', ':', rtrim($matches['0'], '/ '));
        return array(
            'type' => 'rich',
            'provider_name' => 'Spotify',
            'provider_url' => 'https://www.spotify.com',
            'title' => 'Unknown title',
            'html' => '<iframe src="https://embed.spotify.com/?uri=spotify' . $code . '" width="{width}" height="{height}" frameborder="0" allowtransparency="true"></iframe>',
        );
    }
}
?>
READ ALSO
Ошибка jQueryxxxxxxx_xxxxxxxxxxx was not called

Ошибка jQueryxxxxxxx_xxxxxxxxxxx was not called

Получаю эту ошибку jQueryxxxxxxx_xxxxxxxxxxx was not called

266
Кодировка кириллических символов в Telegram

Кодировка кириллических символов в Telegram

Ребят, нужна помощь, кодировка пакетов Update возвращаемых в Telegram (Bot API) кодирована в UTF-8 с BOM'ом из за чего символы на русском языке отображаются...

816
Print_r ($array) - архив списком

Print_r ($array) - архив списком

Print_r ($array) выводит архив подряд текстомКак сделать, чтобы каждый элемент архива начинался с новой строки?

211