我收到警告。
警告:fopen(76561197992146126 .txt):无法打开流: 第6行的C:\ wamp \ www \ Download \ t3.php中的参数无效
对于任何想知道的人,这是下面的main.txt(http://pastebin.com/53chSRRz)
的内容<?php
$APIkey = 'APIKeyHere';
$file = file('C:\wamp\www\Download\main.txt');
foreach ($file as $link) {
$link2 = "http://api.steampowered.com/ITFItems_440/GetPlayerItems/v0001/?key=" . $APIkey . "&SteamID=" . $link . "&format=json";
$downloaded = file_get_contents($link2);
$fh = fopen($link . ".txt", "a"); //or die("can't open file");
fwrite($fh, $downloaded);
}
echo "Finished";
?>
如果我用“静态文件名”替换“fopen($ link。”.txt“,”a“)”,它就可以了。但我需要$ link作为文件名。我的设置势在必行。
我使用WAMP 2.2和PHP 5.4.3运行Windows 7 x64
答案 0 :(得分:6)
您的链接ID中包含空格。尝试在创建$link = trim($link);
之前添加$link2
。