0

When I run the below code I'm getting error as mentioned below:

Error

file_get_contents(https://httpapi.com/api/domains/available.json?auth-userid=711757&api-key=74miSZPgYkkc108Ptmeo5Q8iDTtKk3xi&domain-name=&tlds=): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error

Find the Controller code:

public function available(Request $request)
{
   $domainname = $request['domain-name'];
   $tld = $request['tlds'];

$response = file_get_contents('https://httpapi.com/api/domains/available.json?auth-userid=711757&api-key=74miSZPgYkkc108Ptmeo5Q8iDTtKk3xi&domain-name='.$domainname.'&tlds='.$tld.'')

return view('clientlayout.main.tld',compact( 'response'));
}

This is my route code:

Route::get('/tld','TldController@available');

And in my view I just needed to print the response.

{{print_r($response)}}
Grokify
  • 15,092
  • 6
  • 60
  • 81
sharmila
  • 175
  • 2
  • 19
  • Is there any additional error information in the laravel log ? What is the expected output of your API call ? – Mike Jun 13 '18 at 08:29
  • I need the output like this {"decksys.net":{"classkey":"dotnet","status":"regthroughothers"}} – sharmila Jun 13 '18 at 08:59
  • I think the issue is with the `&` in your error notice. – Mike Jun 13 '18 at 09:06
  • Yes, the issue is in declaring the domain-name in the place of "&amp". Suggest me a solution to solve this – sharmila Jun 13 '18 at 09:21
  • there are several solutions mentioned in this question https://stackoverflow.com/questions/2656940/php-file-get-contents-and-amp i like this one the best http://php.net/manual/en/function.http-build-query.php – Mike Jun 13 '18 at 09:29
  • I think you are not clear with my question - the url of my api contains domain name seperated by hyphen or dash as "domain-name" ... In laravel when I declare this using a variable I'm facing an issue. So please suggest me a solution to declare"domain-name" using a variable... – sharmila Jun 13 '18 at 09:39
  • instead of `$request['domain-name'];` use `$request->query('domain-name');` – Mike Jun 13 '18 at 09:49
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/173053/discussion-between-sharmila-and-mike). – sharmila Jun 13 '18 at 09:53

2 Answers2

0

This might not entirely help, but I've worked with ResellerClub's API quite a bit to the point that we created an SDK wrapper for it, See.

We've not got around to the TDL and domain side of the API, but I know it's something we'll want to do ourselves in the near future. So you could have a look at the repo and see if you can figure it out that way or contribute to the opensource project.

Finally, you have an syntax error of a missing semi colon on the end of file_get_contents. Also you really should be making a GET request to the API either via Guzzle or curl.

Hope that helps.

OAFCROB
  • 81
  • 1
  • 7
0

The following is the API call you had executed:

URL - https://httpapi.com/api/domains/available.json?

Parameters -

auth-userid=reseller id

api-key=API Key

domain-name=

tlds=

Error - HTTP request failed! HTTP/1.1 500 Internal Server Error

You are trying to use an API call to check the availability of a domain name. This is a GET call and you have to specify the correct values in the parameters to get a response containing the domain name availability status for the requested TLDs.

The domain name and the TLD is not specified in the API call you had executed which is the reason for the error “500 Internal Server Error”.

API call Ref link: https://manage.resellerclub.com/kb/answer/764

You can try using the check availability API call using the sample parameters below:

URL - https://domaincheck.httpapi.com/api/domains/available.json?

Parameters -

auth-userid=reseller id

api-key=API Key

domain-name=codeofbelief

tlds=com

The response to the above API call will be “available”.

Depending on the domain name and the TLD you use in the API call, one of the following statuses will be returned:

available - domain name available for registration

regthroughus - domain name currently registered through the Registrar whose connection is being used to check the availability of the domain name

regthroughothers - domain name currently registered through a Registrar other than the one whose connection is being used to check the availability of the domain name. If you wish to manage such a domain name through your Reseller / Registrar Account, you may pass a Domain Transfer API call.

unknown - returned, if, for some reason, the Registry connections are not available. You should ideally re-check the domain name availability after some time.

Laravel is an external application for API creation/development, however, the parameters must be specified correctly for it to return a valid response.

You can always reach out to the support team at ResellerClub if you need any guidance with API execution.

Support URL: https://helpdesk.resellerclub.com/ Kindly log in using your Reseller ID/ Username and your Reseller account PIN/password