Home  >  Article  >  Backend Development  >  file_get_contents请求url接口,出现“request resource is not found”

file_get_contents请求url接口,出现“request resource is not found”

WBOY
WBOYOriginal
2016-06-06 20:15:191759browse

1、我试过这个url在浏览器上请求没问题,但用file_get_contents就出错
2、由于url带的参数有很多字符,所以我用过urlencode格式过,但请求就打不开了
3、需要传参数到这个url接口,有些参数带 =’|| 这些字符,可能这个就是原因,但是要怎么处理
4、这个是url及所带的参数exp:
test.php?exp=pid=="mm_26632469_12350536_47102560"%20||%20pid=="mm_26632469_12350536_47114110"....

回复内容:

1、我试过这个url在浏览器上请求没问题,但用file_get_contents就出错
2、由于url带的参数有很多字符,所以我用过urlencode格式过,但请求就打不开了
3、需要传参数到这个url接口,有些参数带 =’|| 这些字符,可能这个就是原因,但是要怎么处理
4、这个是url及所带的参数exp:
test.php?exp=pid=="mm_26632469_12350536_47102560"%20||%20pid=="mm_26632469_12350536_47114110"....

urlencode的正确用法

<code class="php">'http://www.test.com/path/to/test.php?a='.urlencode('axxxxxxx').'&b='.urlencode('bxxxxxxx').'&c='.urlencode('cxxxxx')</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn