Merge pull request #4 from stoatally/bug-api-method

API method fixes
This commit is contained in:
Jeremy Kauffman 2017-03-29 20:43:43 -04:00 committed by GitHub
commit e66239a972

View file

@ -13,21 +13,22 @@ class LBRY
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['method' => $function, 'params' => $params]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
$serverOutput = curl_exec($ch);
curl_close($ch);
if ($server_output)
if ($serverOutput)
{
$responseData = json_decode($server_output, true);
$responseData = json_decode($serverOutput, true);
if (isset($responseData['error']))
{
throw new Exception($responseData['error']['message'] ?? 'Something unknown went wrong');
}
if (isset($responseData['result']))
{
return $responseData['result'];
}
curl_close ($ch);
return $server_output;
throw new Exception('Received unknown response format.');
}
}
public static function publishPublicClaim($name, $tmpFileName)
@ -54,6 +55,7 @@ class LBRY
public static function findTopPublicFreeClaim($name)
{
$claims = LBRY::api('claim_list', ['name' => $name]);
if (!$claims || !isset($claims['claims']))
{
return null;