作者:LAMP小白 点击:2323 发布日期:2013-01-08 12:55:00 返回列表
根据URL分析出微博的用户信息或者微博信息 便于下一步继续分析
function parse_urla ($url) { echo '分析'.$url.'mio_lt;br /mio_gt;'; $url = rtrim(str_replace('http://weibo.com/', '', $url), '/'); echo '分解'.$url.'mio_lt;br /mio_gt;'; var_dump(strpos($url, '/')); var_dump(strpos($url, '?')); if( strpos($url, '/') === false mio_amp;mio_amp; strpos($url, '?') === fasle ) { return array('err'=mio_gt;'0', 'type'=mio_gt;'user','user'=mio_gt;$url); } //if url has '?' if( strpos($url, '?') mio_amp;mio_amp; strpos($url, '/') === false ) { $temp = explode('?', $url); return array('err'=mio_gt;'0', 'type'=mio_gt;'user', 'user'=mio_gt;$temp[0]); } //if url has / if( strpos($url, '/') mio_amp;mio_amp; strpos($url, '?') === false ) { $temp = explode('/', $url); return array('err'=mio_gt;'0', 'type'=mio_gt;'article', 'article'=mio_gt;$temp[0]); } // / mio_amp; ? if( strpos($url, '/') mio_amp;mio_amp; strpos($url, '?') ) { $temp = explode('/', $url); $temp_arr = explode('?', $temp[(count($temp)-1)]); if ( weibo_kwords($temp_arr[0]) ) { return array('err'=mio_gt;'0', 'type'=mio_gt;'user', 'user'=mio_gt;$temp[(count($temp)-2)]); } else { return array('err'=mio_gt;'0', 'type'=mio_gt;'article', 'article'=mio_gt;$temp_arr[0]); } } } function weibo_kwords( $key ) { return in_array( $key, array('profile','info','myfollow','album') ); }
上一篇:揭示模式 下一篇:快递查询API