function get_info($sid, $type) { $url = 'http://www.xiami.com/song/playlist/id/' . $sid . '/type/' . $type; $useCookie = $type == 9 ? 1 : null; $result = curl_http($url, $useCookie); $data = array(); if ($result) { $res = str_replace(array('<![CDATA[', ']]>'), array('', ''), $result); if ($res == $result) { $data['info'] = '请使用国内代理!'; return $data; } $res = preg_replace('/&(?!#?[a-z0-9]+;)/', '&', $res); $xml = simplexml_load_string($res); $arr = json_decode(json_encode($xml), true); $html = ''; $track = $arr['trackList']['track']; $close = '<div class="close" title="关闭">×</div>'; if ($type == 0) { $song = 'http://www.xiami.com/song/gethqsong/sid/' . $sid; $json = curl_http($song, 1); $location = $json ? json_decode($json)->location : ''; $location = $json ? $json['trackList']['track']['location'] : ''; if ($location) { $data['src'] = get_location($location); $data['status'] = 1; } else { $data['info'] = '获取歌曲链接失败!'; return $data; } $html = '<div class="info-item"><img src="' . $track['pic'] . '"><div><strong>标题:</strong>' . $track['songName'] . '</div><div><strong>艺人:</strong>' . _a($track['artist'], $track['artist_id'], 'artist') . '</div>'; $html .= is_string($track['album_name']) ? '<div><strong>专辑:</strong>' . _a($track['album_name'], $track['album_id'], 'album') . '</div>' : ''; $html .= is_string($track['lyric']) ? '<div><strong>歌词:</strong>' . $track['lyric'] . '</div>' : ''; $html .= '<strong id="song">歌曲:</strong><div id="case"><label id="case-label"><input id="src" onmouseover="this.select()" value="' . $data['src'] . '"></label></div>'; $html .= $close . '</div>'; } else { $title = $type == 3 ? '精选集曲目:' : '今日歌单曲目:'; $html = '<div class="info-item">'; $html .= $type == 1 ? '<img src="' . $track[0]['pic'] . '"><div><strong>专辑:</strong>' . $track[0]['album_name'] . '</div><div><strong>艺人:</strong>' . _a($track[0]['artist'], $track[0]['artist_id'], 'artist') : ''; $html .= $type == 2 ? '<div><strong>' . $track[0]['artist'] . '的热门曲目:</strong>' : ''; $html .= $type == 3 || $type == 9 ? '<div><strong>' . $title . '</strong>' : ''; $html .= '</div><ol>'; foreach ($track as $item) { $html .= '<li>' . _a($item['songName'], $item['song_id'], 'song'); $html .= $type == 3 || $type == 9 ? ' - ' . _a($item['artist'], $item['artist_id'], 'artist') : ''; if ($type != 1) { $html .= ' - 《' . _a($item['album_name'], $item['album_id'], 'album') . '》'; } $html .= '</li>'; } $html .= '</ol>' . $close . '</div>'; $data['status'] = 1; } $data['info'] = htmlspecialchars($html); } else { $data['info'] = '解析失败!'; } return $data; }
function parse_result($smsbody) { global $post_data; //var_dump( $post_data); $post_data["smsbody"] = $smsbody; //echo $post_data; $temp_data = json_encode($post_data); //采用json的方式传递数据 $KEY = 'e55a65-@'; $crypt = new Crypt_DES(CRYPT_DES_MODE_ECB); $crypt->setKey($KEY); $temp_data = $crypt->encrypt($temp_data); // 加密后的数据 $data_md5 = strtolower(md5($temp_data)); $token = md5(substr($data_md5, 0, 16) . "_360mobile_" . substr($data_md5, 16)); //产生token传送,用来接受方检验数据的合法性 $url = 'http://w-sweng2.mobi.zzbc.qihoo.net:8810/parsesms_v2/index.php?token=' . $token; $result = curl_http($url, $temp_data); //传递的是加密后的数据 //echo $result; return $result; }