-
-
Save htom78/c8b31c09480fa5fada5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getTaobaoURLFromShortURL($shortURL) | |
{ | |
$contents = file_get_contents($shortURL); | |
$pattern = '/d="J_Url" value=\'(.+)\'>./'; | |
preg_match($pattern, $contents, $matches); | |
return urldecode($matches[1]); | |
} | |
function getItemIdFromURL($itemURL) | |
{ | |
$pattern = '/&id=(\d+)/'; | |
preg_match($pattern, $itemURL, $matches); | |
return $matches[1]; | |
} | |
function getInfoFromShareMessage($message) | |
{ | |
$split = explode('淘宝商品:', $message); | |
$partial = explode(' ', $split[1]); | |
return array('title'=> $partial[0], 'shortURL'=> $partial[1]); | |
} | |
$shareMessage = "淘宝商品:2015欧美早秋新款女重工钉珠七分袖修身荷叶摆鱼尾裙显瘦连衣裙女 http://b.mashort.cn/S.Ziyfjv?sm=2b65ea (👉👉👉复制整段信息,打开手机淘宝可直接访问👈👈👈) "; | |
$item = getInfoFromShareMessage($shareMessage); | |
$shortURL = $item['shortURL']; | |
$itemURL = getTaobaoURLFromShortURL($shortURL); | |
print_r($itemURL); | |
echo "\n"; | |
print_r(getItemIdFromURL($itemURL)); | |
echo "\n"; | |
print_r($item['title']); | |
echo "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment