php 怎么获取真实连接
假设现在有件商品连接
http://click.simba.taobao.com/cc_im?p=&s=2007066312&k=353&e=5nV7VfZNmwD2DkjkRxdyQwLivSlPBaWVpGWV9xGSS7V5ZF%2BaL%2Bx5n%2BL%2BcR5UFwLbMUeb8tpE664fJSqCTB8CrhVUyNhjYNDnPmYv%2BmL5fyH0gzcJo24jnpi0x%2BGaElnjPaVDY8eZMzr%2BRVVTGr94t6QOZrzzNcTkWShWwUIivlYq%2BVuJw%2Fv%2BcgVGGYVBBPKbZsG9tZXOkgsCgs2J%2B5cW7ZLEKs8Rxiq6sNdg4%2F1tiMHvYjNMeY%2FYOVyjLkclW3N6%2Ft7WdgY5I5HwlFYoULQfe6kI5BDzswotE6BbpY58c7b6UBlprFqwZmIr%2FcfSfA7fuJQB3DAtsMO59X3DsN%2Fg25d%2B4hyRLy%2FJ
乱七八糟的,加密连接
但是打开之后可以发现连接是
http://detail.tmall.com/item.htm?id=16945055954&ali_refid=a3_420432_1006:1103639795:6:%D6%D0%C7%EF%D4%C2%B1%FD:0b976cf57c16ab586837953af5290eeb&ali_trackid=1_0b976cf57c16ab586837953af5290eeb
可以看到里面有各种参数, 我想获取的是ID
我刚开始想通过
curl 来发送这个连接 然后用 HTTP__REFERER 来获取,发现不好使,
请问还有什么方法 能获取到真实连接
------解决方案--------------------
这个是淘宝客的链接吧.如果是自己的可以通过淘宝客api获取.
------解决方案--------------------
只不过是你打开第一个链接后他内部做了一次跳转。使用curl的CURLOPT_FOLLOWLOCATION参数就可以实现跟随他的跳转。
------解决方案--------------------
用CURLOPT_HEADER解析源地址的header部分,然后正则取出location,这里的location 就是 跳转后的地址
$ch2 = curl_init(); curl_setopt($ch2, CURLOPT_URL, "http://click.simba.taobao.com/cc_im?p=&s=2007066312&k=353&e=5nV7VfZNmwD2DkjkRxdyQwLivSlPBaWVpGWV9xGSS7V5ZF%2BaL%2Bx5n%2BL%2BcR5UFwLbMUeb8tpE664fJSqCTB8CrhVUyNhjYNDnPmYv%2BmL5fyH0gzcJo24jnpi0x%2BGaElnjPaVDY8eZMzr%2BRVVTGr94t6QOZrzzNcTkWShWwUIivlYq%2BVuJw%2Fv%2BcgVGGYVBBPKbZsG9tZXOkgsCgs2J%2B5cW7ZLEKs8Rxiq6sNdg4%2F1tiMHvYjNMeY%2FYOVyjLkclW3N6%2Ft7WdgY5I5HwlFYoULQfe6kI5BDzswotE6BbpY58c7b6UBlprFqwZmIr%2FcfSfA7fuJQB3DAtsMO59X3DsN%2Fg25d%2B4hyRLy%2FJ"); curl_setopt($ch2, CURLOPT_HEADER, true); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); $orders = curl_exec($ch2); preg_match_all('/^Location: (?P<location>.*?)$/m', $orders, $matches); curl_close($ch2); echo $matches['location'][0]; <div class="clear"> </div></location>