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