I want to check the availability of domain through API. Other api is working perfectly but the "DomainWhois" api is not working as expected.
I have tried the following code which was available at WHMCS.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(
array(
'action' => 'DomainWhois',
// See https://developers.whmcs.com/api/authentication
'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
'password' => 'SECRET_OR_HASHED_PASSWORD',
'domain' => 'example.com',
'responsetype' => 'json',
)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);```
I have use the above code with my credentials but got below response for every domain check.
{"result" => "success" "status" => "error" "whois" => ""}
Related
I'm integrating the Instamojo payment gateway into a website using core PHP.
I wrote some script that is working well enough on the test.instamojo.com (Which is a test version of their portal) but When I changed the credentials for the live testing (means I have removed test level credentials and put all real-time credentials like their live URL, Private key, Auth Key of our account) It's started showing error in the variable where I want to receive the long URL to redirect for the payment.
The Instamojo response is
{
"success": true,
"payment_request": {
"id": "47a321d9*****************bbb55f64",
"phone": "+9170******55",
"email": "a*******#gmail.com",
"buyer_name": "Aman",
"amount": "100.00",
"purpose": "FIFA",
"expires_at": null,
"status": "Pending",
"send_sms": true,
"send_email": true,
"sms_status": "Pending",
"email_status": "Pending",
"shorturl": null,
"longurl": "https://www.instamojo.com/#EXAMPLE/47a321d95c5c4d7f8e0e7742bbb55f64",
"redirect_url": "http://www.example.com/thankyou.php/",
"webhook": null,
"allow_repeated_payments": false,
"created_at": "2022-09-10T09:16:12.104302Z",
"modified_at": "2022-09-10T09:16:12.104336Z"
}
}
This is my Php Code
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.instamojo.com/api/1.1/payment-requests/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("X-Api-Key:*****************************************",
"X-Auth-Token:**************************************"));
$payload = Array(
'purpose' => 'FIFA',
'amount' => '100',
'phone' => '70*****55',
'buyer_name' => 'Aman',
'redirect_url' => 'http://www.example.com/thankyou.php/',
'send_email' => true,
'send_sms' => true,
'email' => 'a******#gmail.com',
'allow_repeated_payments' => false
);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
$response = curl_exec($ch);
curl_close($ch);
header('location:'.$response->payment_request->longurl);
?>
I'm getting an error (red line within $ response) at
header('location:'.$response->payment_request->longurl);
The use of json_decode() and traverse to data you want
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.instamojo.com/api/1.1/payment-requests/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("X-Api-Key:*****************************************",
"X-Auth-Token:**************************************"));
$payload = Array(
'purpose' => 'FIFA',
'amount' => '100',
'phone' => '70*****55',
'buyer_name' => 'Aman',
'redirect_url' => 'http://www.example.com/thankyou.php/',
'send_email' => true,
'send_sms' => true,
'email' => 'a******#gmail.com',
'allow_repeated_payments' => false
);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
$response = curl_exec($ch);
curl_close($ch);
header('location:'.json_decode($response, true)['payment_request']['longurl']);
?>
I am trying to create a new list via the mailchimp api, I have tried tweaking the code so much but keep getting the error:
{"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid Resource","status":400,"detail":"The resource submitted could not be validated. For field-specific details, see the 'errors' array.","instance":"0174d737-b3d4-40a6-9cd4-e934ed8578a7","errors":[{"
field":"","message":"Schema describes object, NULL found instead"}]}
My code (api key is valid):
$data = array( // the information for your new list--not all is required
"name" => $name,
"contact" => array (
"company" => $company,
"address1" => $address1
),
"permission_reminder" => $permission_reminder,
"use_archive_bar" => $archive_bars,
"campaign_defaults" => array(
"from_name" => $from_name,
"from_email" => $from_email,
"subject" => $subject,
"language" => $language
),
"notify_on_subscribe" => $notify_subs,
"notify_on_unsubscribe" => $notify_unsubs,
"email_type_option" => $type,
"visibility" => $visibility
);
$ch = curl_init("https://$dataCenter.api.mailchimp.com/3.0/lists/");
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
print_r($result); // display API response
I'm not seeing any JSON encoding of your payload in the code you provided. You will need to json_encode() your payload ($data) in order for MailChimp to be able to read it.
Like this:
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
I've been trying to create an account under a registrar account on Bitshares Test Net programatically using Graphene API and its blockchain. I read the API documentation and have concluded that the PHP code bellow is what I need to execute to be able to create a new account.
<?php
$url = 'https://testnet.bitshares.eu/';
$array = array(
'jsonrpc' => '2.0',
'method' => 'register_account',
'params' => array(
'name' => 'NEW_ACCOUNT_NAME',
'owner_key' => 'OWNER_KEY',
'active_key' => 'ACTIVE_KEY',
'registrar_account' => 'REGISTRAR_ACCOUNT',
'referrer_account' => 'REGISTRAR_ACCOUNT',
'referrer_percent' => 1,
'broadcast' => 1
),
'id' => 1
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'GraphenePHP/1.0');
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array));
$response = curl_exec($ch);
curl_close($ch);
echo '<pre>';
print_r($response);
echo '</pre>';
The code above is not working. Also I am not getting any response. I have a feeling that I am missing something or the value of $url is incorrect.
Please help?
This Bitshares testnet link https://testnet.bitshares.eu/ sometimes does not work.
You can simply use real net or install testnet on your side for this.
I am working on Canvas LMS and have access token. I need to create an user account using web service in PHP. I have tried to do it using CURL (post method) but getting an error in response. However GET is working fine.
Like if I need to get information about course etc, it's working fine but account creation not working using CURL (post). Below is my code.
$url = "https://xxxxx.com/api/v1/accounts/2/users";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' .$token ) );
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
'name' => 'vaue',
'short_name' => 'value',
'unique_id' => '1121',
));
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_ENCODING, "");
$curlData = curl_exec($curl);
curl_close($curl);
Error:
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[message] => An error occurred.
[error_code] => internal_server_error
)
)
[error_report_id] => 1124
)
I resolved my issue. The reason of "internal server error" was not sending required fields. Here are the required fields if someone need to know.
'user[name]' => '',
'user[terms_of_use]' => 'true',
'pseudonym[unique_id]' => '',//i.e valid email
'pseudonym[send_confirmation]'=>'true'
Now my CURL request is working fine and I am able to create an account successfully.
It looks like the keys for your arguments are incorrect. They should be:
'user[name]' => 'vaue',
'user[short_name]' => 'value',
'pseudonym[unique_id]' => '1121',
You can find the docs for your canvas install at: "https://{your canvas domain}/doc/api/index.html" or if you are using cloud hosted canvas at "api.instructure.com"
I want to create a webhook url for pitifuller form by id here is my code i don't know what is my mistake
define('CLIENT_ID', 'client_id');
define('CLIENT_SECRET', 'client_secret');
define('REDIRECT_URL', 'redirect url'); // for testing, use the URL to this PHP file.
define('AUTHORIZE_URL', 'https://www.formstack.com/api/v2/oauth2/authorize');
define('TOKEN_URL', 'https://www.formstack.com/api/v2/oauth2/token');
$ch = curl_init(TOKEN_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
'grant_type' => 'authorization_code',
'client_id' => CLIENT_ID,
'redirect_uri' => REDIRECT_URL,
'client_secret' => CLIENT_SECRET,
'id' => 'id', // here is my id
'url' => 'web_hook_url' // here is my webhook url which i want to create
)));
// oauth2 contains the the access_token.
$oauth2 = json_decode(curl_exec($ch));
You did mistake in your CURL call, currently you are pass post data in GET form and you need to pass Like this(POST form/:id/webhook), and you can do this:
$ch = curl_init('https://www.formstack.com/api/v2/form/your-form-id/webhook');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $oauth2->access_token
));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
'id' => $_POST['id'],
'url' => 'http://www.getbravo.com/formstack/index.php',
'append_data' => '1'
)));
and you get response like this
$forms = json_decode(curl_exec($ch));
print '<pre>';
print_r($forms);
print '</pre>';