我创建了一个php脚本,它将网页url作为这样的参数获取。 http://example.com index.php file
<?php
$url = $_REQUEST["url"];
echo $url;
请求就像这样
http://example.com?url=http://myproxyapi.com/api?request=Get&format=image/png&width=20&height=20
这个请求写了这个屏幕:
http://myproxyapi.com/api?request=Get
实际上它应该写:
http://myproxyapi.com/api?request=Get&format=image/png&width=20&height=20
如果我得到这个网址,我会拆分它。
答案 0 :(得分:2)
此网址无效:
http://example.com?url=http://myproxyapi.com/api?request=Get&format=image/png&width=20&height=20
你必须在网址的查询部分内转义字符,所以像:/?
这样的字符。
php为此提供了函数urlencode():
sprintf('http://example.com?url=%s',
urlencode('http://myproxyapi.com/api?request=Get&format=image/png&width=20&height=20'));