How to pass values in resellerclub API using Laravel - laravel

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)}}

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.

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

Related

Why is my TC not working when it should in Jmeter?

I am new to JMetet and I am having a lot of difficulties in understanding how it works.
I created a TC to add an object to my system using Blaze meter. Then, I imported the TC in Jmeter.
This TC fails when it should not (at least thats what I think) because whenever I use the system it works correctly:
This is the thread group if you need it to help me:
Am I doing something wrong? AM I missing something?
IMPORTANT: Should I be able to see my object added to the system if the TC passes?
As per HTTP Status Code 403 Forbidden description:
The HTTP 403 Forbidden client error status response code indicates that the server understood the request but refuses to authorize it.
This status is similar to 401, but in this case, re-authenticating will make no difference. The access is permanently forbidden and tied to the application logic, such as insufficient rights to a resource.
If your script assumes authentication most probably it fails somewhere somehow due to missing or improperly working correlation, for example this eedd968fe... bit
looks utterly suspicious, most probably you need to replace it with a some form of dynamic parameter extracted from the previous request using a suitable JMeter Post-Processor
Normally the flow looks like:
Open login page
Identify and extract all dynamic parameters and save them into JMeter Variables
Send the parameters along with credentials in the 2nd request
Check out Using Regular Expressions to Extract Tokens and Session IDs to Variables article for example challenge and solution

Can not call Alibaba Cloud API

I am using Alibaba Cloud. I have followed the document to use API to query a group.
For example: I use http://apigateway.cn-hangzhou.aliyuncs.com?Action=DescribeApiGroup
&GroupId=xxx&AccessKeyId=xxx.
I got the error InvalidVersion: Specified parameter Version is not valid.
If you faced this error, please help me how to call the API. Thanks
The APIs of the API Gateway are called by sending HTTP GET requests with corresponding request parameters included in the requests according to the interface instructions. The system returns processing results according to the request processing status.
The problem with your query is that the server is expecting more parameters and you are only passing Action, GroupId and AccessKeyId. And when the server is not finding the Version parameter in your query, it is throwing the InvalidVersion error.
Here is a list of required parameters that you are missing in your request:
Version
Signature
SignatureMethod
SignatureNonce
SignatureVersion
TimeStamp
An example of a valid request would be:
https://apigateway.cn-hangzhou.aliyuncs.com/?Format=xml
&Version=2016-07-14
&Signature=Pc5WB8gokVn0xfeu%2FZV%2BiNM1dgI%3D
&SignatureMethod=HMACSHA1
&SignatureNonce=15215528852396
&SignatureVersion=1.0
&AccessKeyId=key-test
&TimeStamp=2016-08-08T08:00:00Z
However, the format parameter is not strictly required. For more information on the request parameters, you can visit https://www.alibabacloud.com/help/doc-detail/43597.htm

Sending AJAX request without querystring parameters as 'referrer'

I'm trying to communicate to Google Calendar API.
The API only accepts requests from a specific referrer, e.g.: www.mysite.com/calendar/events.asp
But sometimes the URL includes querystring parameters, e.g.:
www.mysite.com/calendar/events.asp?message=eventAddedSuccessfully&id=50
The API rejects requests from the above URL, and returns this message:
"The referrer www.mysite.com/calendar/events.asp?message=eventAddedSuccessfully&id=50 does not match the referrer restrictions configured on your API key. Please use the API Console to update your key restrictions."
How can I send an AJAX request with only the path in the URL as the referrer?
Thanks
Change your restriction to cater the context path of the domain, it may be specific to that page (and possibly treats it differently with parameters) and causes the issue you're encountering.
www.mysite.com/*
or
www.mysite.com/calendar/*
Hopefully this will resolve the issue.

Http status code for bad params in post request

I have a server in which the client can register itself as a device (like a mobile device). For the registration, the device must be associated with another resource (say an user) which is already registered on the server. To do that, the client sends a Http Post request to the server, with two params, its own ID and the associated resource ID.
I need to choose an Http Status code to return when the client ask the server to do some procedure and one of the resources indicated in the parameters are not found.
I suggested 404, but my professor said that 404 is used the resource associated to the URI is not found, not when you submit a well-formed request with bad parameters.
What is the most suitable http status and why would you choose?
In my opinion, it fits to:
400 - Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
OR
403 - Forbidden
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.
Ref: fc2616
I would use 403 'Forbidden' - meaning, you are forbidden from accessing the page with the request you have sent

Trying to call parse.com cloud function using maigun route action

I'm trying to use a parse.com cloud function in a mailgun route action (forward).
My action is like this (with my app id and JS key included of course):
forward("https://myAppId:javascript-key:myJSkey#api.parse.com/1/functions/hello")
In the mailgun logs, I see it call, but I get the following error:
HTTP Error 401: Unauthorized Server response: 401 HTTP Error 401: Unauthorized
My function is just a simple response.send("OK");
Obviously I'm missing something.
Greg
The issue I think is that the Cloud Code calling convention requires you use special Parse headers, not just keys: it may be different if its being called from a browser with sets the referer headers. I'm not sure you'll be able to call it this way directly from Mailgun: you may need a proxy of some sort.
EDIT: I think you'll need to use the Express Webhook implementation instead, and then you can use standard basic authentication. Cloud Code is really for cases where you have control over the HTTP client you're using.

Resources