Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cURL error code 3: Malformed url #2

Closed
Nganyu opened this issue Dec 14, 2021 · 6 comments
Closed

cURL error code 3: Malformed url #2

Nganyu opened this issue Dec 14, 2021 · 6 comments

Comments

@Nganyu
Copy link

Nganyu commented Dec 14, 2021

I have been trying to configure te API bit on my codeignter project hosted on a plesk server . i have serious issues. The error code when i call masterdata or cashout get is

An error occured: string(75) "[0] cURL error 3: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)" NULL string(710) "#0 /var/www/vhosts/trusting-ride.217-160-71-127.plesk.page/ci/application/vendor/maviance/smobilpay-php/src/Service/AccountApi.php(103): Maviance\S3PApiClient\Service\AccountApi->accountGetWithHttpInfo() #1 /var/www/vhosts/trusting-ride.217-160-71-127.plesk.page/ci/application/helpers/rc_helper.php(108): Maviance\S3PApiClient\Service\AccountApi->accountGet() #2 /var/www/vhosts/trusting-ride.217-160-71-127.plesk.page/ci/application/controllers/App.php(122): masterdata() #3 /var/www/vhosts/trusting-ride.217-160-71-127.plesk.page/ci/system/core/CodeIgniter.php(532): App->masterdata() #4 /var/www/vhosts/trusting-ride.217-160-71-127.plesk.page/ci/index.php(315): require_once('/var/www/vhosts...') #5 {main}"

From my research this corresponds to a malformed URL. I have tried every possible solution to know avail.

@dani-gouken
Copy link
Contributor

dani-gouken commented Dec 14, 2021

Hello @Nganyu
Please make sure to call the setHost method in the Configuration object with a valid url, like in the example below:

<?php

use Maviance\S3PApiClient\ApiClient;
use Maviance\S3PApiClient\Configuration;

require_once(__DIR__ . '/vendor/autoload.php');

$token = "public access key";
$secret = "access secret";

$xApiVersion = "3.0.0"; // string | api version info
$config = new Configuration();

///HERE
$url = "https://example.com";
$config->setHost($url);

$client = new ApiClient($token, $secret, ['verify' => true]);

$apiInstance = new Maviance\S3PApiClient\Service\AccountApi($client,$config);

try {
    $result = $apiInstance->accountGetWithHttpInfo($xApiVersion);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AccountApi->accountGet: ', $e->getMessage(), PHP_EOL;
}
?>

Maybe the variable that you are passing to setHost is null?

@Nganyu
Copy link
Author

Nganyu commented Dec 14, 2021

Hi, Thanks much, I have checked that and made sure of that properly.

`<?php

use Maviance\S3PApiClient\ApiClient;
use Maviance\S3PApiClient\Configuration;

include_once(APPPATH."/vendor/autoload.php");
//require_once APPPATH."/third_party/PHPExcel.php";

//$env = "stag";
$url = "https://s3p.smobilpay.staging.maviance.info/v2/"; //"https://s3papi.cmstaging.smobilpay.net/v2";
$token = ''";
$secret = '"';

$config = new Configuration();
$config->setHost($url);
$config->setDebugFile("api.log");
$config->setDebug(false);

// set "verify" to false to disable ssl verification
$client = new ApiClient($token, $secret, ['verify' => false]);

$version = "3.0.0";
?>`

Yet i get thesame issues.

@Nganyu
Copy link
Author

Nganyu commented Dec 14, 2021

Also it works pretty good on localhost, but throws that error on my server. cURL is enabled and i have ran composer update a couple of times.

@dani-gouken
Copy link
Contributor

Hello, please do not expose your credentials here. those issues are public

@dani-gouken
Copy link
Contributor

dani-gouken commented Dec 15, 2021

This works correctly in our end.

<?php

use Maviance\S3PApiClient\ApiClient;
use Maviance\S3PApiClient\Configuration;
use Maviance\S3PApiClient\Service\AccountApi;

require_once(__DIR__ . '/vendor/autoload.php');

//$env = "stag";
$url = "https://s3p.smobilpay.staging.maviance.info/v2"; //"https://s3papi.cmstaging.smobilpay.net/v2";
$token = 'your-token';
$secret = 'your-secret';

$config = new Configuration();
$config->setHost($url);
$config->setDebugFile("api.log");
$config->setDebug(false);

// set "verify" to false to disable ssl verification
$client = new ApiClient($token, $secret, ['verify' => false]);
$apiInstance = new AccountApi($client,$config);

$version = "3.0.0";
$result = $apiInstance->accountGetWithHttpInfo($version);
?>

Send your error message here, so that we can review. Make sure it is related to this package.

@dani-gouken
Copy link
Contributor

Closing as we are waiting for user feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants