Help on CURL Json

Asked

Viewed 75 times

0

I have a Curl code, which pulls json by url, but is giving an error that I can not solve, someone can help me?

<?php
$c = curl_init();
$login = 'LOGIN';
$key = 'KEY';
$file = $_GET["fileid"];
curl_setopt($c, CURLOPT_URL, "https://api.openload.io/1/file/dlticket?file={$file}&login={$login}&key={$key}");
curl_setopt($c,  CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($c);
$response = json_decode($response);
$output = get_object_vars($response);
$result = get_object_vars($output['result']);
$ticket = $result['ticket'];
$captcha = $result['captcha_url'];
curl_setopt($c, CURLOPT_URL, "https://api.openload.io/1/file/dl?file={$file}&ticket={$ticket}&captcha_response={$captcha}");
curl_setopt($c,  CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($c);
$response = json_decode($response);
$output = get_object_vars($response);
$downloadOutput = get_object_vars($output['result']);
$downloadLink = $downloadOutput['url'];
header("Location:  $downloadLink");
// If no File name is provided then this form is used
 $pageName = basename($_SERVER['PHP_SELF']);
if (empty($file)) {
echo '
<html>
	<body>
		<form action="' . $pageName . '" method="get">
		Enter the File ID: <input type="text" name="fileid"><br>
		<input type="submit">
		</form>
	</body>
</html>
';
}
?>

Error:

Warning: get_object_vars() expects parameter 1 to be object, null given in C:\AppServ\www\novo.php on line 10

  • prints what’s coming in $Sponse before doing jsondecode

  • You can help me, how would you look?

  • after that line $Response = curl_exec($c); places var_dump($Response);die; and see what comes out as return

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.