国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁 微信小程式 微信開發(fā) 微信公眾平臺(tái)開發(fā)線上點(diǎn)歌功能介紹

微信公眾平臺(tái)開發(fā)線上點(diǎn)歌功能介紹

Mar 23, 2017 am 11:58 AM

? ? 微信大眾平臺(tái)的訊息介面-音樂訊息,這是廣大微信大眾平臺(tái)開發(fā)者的福音。 根據(jù)這項(xiàng)功能,如果能做出在微信中點(diǎn)歌功能,那麼我們以後就可以不用安裝其他APP, 直接在微信裡面關(guān)註一個(gè)帳號(hào),就可以聽歌了,還省去了安裝的麻煩,而且不用再佔(zhàn)空間。如果音樂資源夠好,那麼將秒殺一切手機(jī)上線上聽歌軟體也不是沒有可能的。

回覆音樂訊息

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>12345678</CreateTime>
<MsgType><![CDATA[music]]></MsgType>
<Music>
<Title><![CDATA[TITLE]]></Title>
<Description><![CDATA[DESCRIPTION]]></Description>
<MusicUrl><![CDATA[MUSIC_Url]]></MusicUrl>
<HQMusicUrl><![CDATA[HQ_MUSIC_Url]]></HQMusicUrl>
<ThumbMediaId><![CDATA[media_id]]></ThumbMediaId>
</Music>
</xml>

微信公眾平臺(tái)開發(fā)線上點(diǎn)歌功能介紹

核心程式碼:

public function getMusicInfo() {
             
            if ($this->name == ""){
                $content = array( "Title"=>"",
                        "Description"=>"你還沒告訴我音樂名稱呢?",
                        "MusicUrl"=>"",
                        "HQMusicUrl"=>"");
                 
            } else {
                if (strpos($this->name, "+")){
                    $music = explode("+",$this->name);
                    $url = "http://box.zhangmen.baidu.com/x?op=12&count=1&title=".$music[1]."$$".$music[0]."$$$$";
                }else{
                    $url = "http://box.zhangmen.baidu.com/x?op=12&count=1&title=".$this->name."$$";
                }
             
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $data = curl_exec($ch);
                $content = array( "Title"=>"歌曲【".$this->name."】",
                        "Description"=>"檢索失敗",
                        "MusicUrl"=>"",
                        "HQMusicUrl"=>"");
                try{
                    @$menus = simplexml_load_string($data, &#39;SimpleXMLElement&#39;, LIBXML_NOCDATA);
                    if ($menus->count > 0 && isset($menus->url[0]) && isset($menus->durl[0])){
                        $url_prefix = substr($menus->url[0]->encode,0,strripos($menus->url[0]->encode,&#39;/&#39;) + 1);
                        $url_suffix = substr($menus->url[0]->decode,0,strripos($menus->url[0]->decode,&#39;&&#39;));
                        $durl_prefix = substr($menus->durl[0]->encode,0,strripos($menus->durl[0]->encode,&#39;/&#39;) + 1);
                        $durl_suffix = substr($menus->durl[0]->decode,0,strripos($menus->durl[0]->decode,&#39;&&#39;));
                        if (strpos($this->name, "+")){
                            $content = array( "Title"=>$music[1],
                                    "Description"=>$music[0],
                                    "MusicUrl"=>$url_prefix.$url_suffix,
                                    "HQMusicUrl"=>$durl_prefix.$durl_suffix);
                        }else{
                            $content = array( "Title"=>$this->name,
                                    "Description"=>"百度音樂提供",
                                    "MusicUrl"=>$url_prefix.$url_suffix,
                                    "HQMusicUrl"=>$durl_prefix.$durl_suffix);
                        }
                    }
                }catch(Exception $e){
                }
            }
            return $content;
        }

介面呼叫:

include (&#39;music.class.php&#39;);
$m = new MusicApi($musicContent);
$mArr = $m->getMusicInfo();
return $this->responseMusic($mArr["Title"], $mArr["Description"], $mArr["MusicUrl"], $mArr["HQMusicUrl"], 0);

效果示範(fàn):

微信公眾平臺(tái)開發(fā)線上點(diǎn)歌功能介紹

以上是微信公眾平臺(tái)開發(fā)線上點(diǎn)歌功能介紹的詳細(xì)內(nèi)容。更多資訊請(qǐng)關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

本網(wǎng)站聲明
本文內(nèi)容由網(wǎng)友自願(yuàn)投稿,版權(quán)歸原作者所有。本站不承擔(dān)相應(yīng)的法律責(zé)任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請(qǐng)聯(lián)絡(luò)admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅(qū)動(dòng)的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強(qiáng)大的PHP整合開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)程式碼編輯軟體(SublimeText3)

熱門話題

Laravel 教程
1601
29
PHP教程
1502
276