Hallo ich möchte gerne eine ausgelesene json in eine php datei speichern,
leider sind meine versuche mit file_put_contents erfolglos :-(
Vielleicht kann mir jemand sagen warum.....
dazu hab ich dann schon mal folgendes probiert
die datei wird da zwar angelegt aber es steht nur eine 1 drin
P.S. echo $result; funktioniert einwandfrei
leider sind meine versuche mit file_put_contents erfolglos :-(
Vielleicht kann mir jemand sagen warum.....
PHP:
//API Url
$url = 'https://apiurl.com/?api_key=99999999888888777777';
//Initiate cURL.
$ch = curl_init($url);
//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
//Execute the request
$result = curl_exec($ch);
dazu hab ich dann schon mal folgendes probiert
PHP:
$file = 'test.php';
file_put_contents($file, $result);
die datei wird da zwar angelegt aber es steht nur eine 1 drin
P.S. echo $result; funktioniert einwandfrei