file_get_contents() returns an empty string when authenticating, otherwise fine

StackOverflow https://stackoverflow.com/questions/5954840

  •  07-11-2019
  •  | 
  •  

문제

So, I'm new to working with API's and PHP, so bear with me. I'm trying to hit an API to authenticate into the site via GET parameters (as suggested in the API documentation). I'm trying to use file_get_contents() to return the authentication token it returns. A redirect to the URL outputs the token in XML format.

However, when I do the following, it returns an empty string. How can I return the full XML output?

$token = file_get_contents('http://example.com/api.asp?cmd=logon&email=xxx@something.com&password=s0mep@SSword');
var_dump($token);

I get the following output:

string(116) ""

Any ideas about what I'm doing wrong?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top