i tried to connect to my xmpp server using php with this library: https://github.com/fabiang/xmpp but get this following error:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /var/www/html/cobaxmpp/vendor/fabiang/xmpp/src/Stream/SocketClient.php on line 210
here is my code
<?php
$logger = new Logger('xmpp');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
$hostname = 'im2.hprasetyou.com';
$port = 5222;
$connectionType = 'tcp';
$address = "$connectionType://$hostname:$port";
$username = 'tom';
$password = 'password';
$options = new Options($address);
$options->setLogger($logger)
->setUsername($username)
->setPassword($password);
$client = new Client($options);
$client->connect();
$client->send(new Roster);
$client->send(new Presence);
$client->send(new Message);
$client->disconnect();
what am i missing?
Related
I tried to connect MQTTS with my HTTPS server but it didn't work. It works fine on MQTTX but with PHP it doesn't connect.
<?php
$server = 'myServer';
$port = '8883';
$clientId = 'testing';
$username = 'XXXX';
$password = 'XXXX';
$clean_session = false;
$connectionSettings = new ConnectionSettings();
$connectionSettings->setUsername($username)
->setPassword($password)
->setKeepAliveInterval(60)
->setLastWillTopic('mytopic')
->setLastWillMessage('client disconnect')
->setLastWillQualityOfService(1);
$mqtt = new MqttClient($server, $port, $clientId);
$mqtt->connect($connectionSettings, $clean_session);
$mqtt->subscribe('mytopic/respond', function ($topic, $message) use ($mqtt) {
echo $message;
}, 2);
$mqtt->close();
$mqtt->interrupt();
?>
How to connect MQTTS with PHP.
Looking at the source code for the phpMQTT library you need to pass a cafile in the constructor to enable a SSL/TLS connection.
$mqtt = new MqttClient($server, $port, $clientId, $cafile);
Where the cafile is the path to a CA certificate to validate the broker.
OK, first answer was against the wrong phpMQTT library, trying again.
The correct library is here: https://github.com/php-mqtt/client
From the doc:
// This flag determines if TLS should be used for the connection. The port which is used to
// connect to the broker must support TLS connections.
->setUseTls(false)
e.g.
$connectionSettings->setUsername($username)
->setPassword($password)
->setKeepAliveInterval(60)
->setLastWillTopic('mytopic')
->setLastWillMessage('client disconnect')
->setUseTls(true)
->setLastWillQualityOfService(1);
For connecting MQTTS we need to add three additional params into the connectionSettings
->setUseTls(true)
->setTlsSelfSignedAllowed(true) // Allow self-signed certificates. Discouraged for production use.
->setTlsVerifyPeer(false) // Do not require the self-signed certificate to match the host. Discouraged.
https://github.com/php-mqtt/client-examples/blob/master/03_connection_settings/02_use_tls_without_client_certificate.php
<?php
$server = 'myServer';
$port = '8883';
$clientId = 'testing';
$username = 'XXXX';
$password = 'XXXX';
$clean_session = false;
$connectionSettings = (new ConnectionSettings)
->setUsername($username)
->setPassword($password)
->setKeepAliveInterval(60)
->setLastWillTopic('mytopic')
->setLastWillMessage('client disconnect')
->setUseTls(true)
->setTlsSelfSignedAllowed(true) // Allow self-signed certificates. Discouraged for production use.
->setTlsVerifyPeer(false) // Do not require the self-signed certificate to match the host. Discouraged.
->setLastWillQualityOfService(1);
$mqtt = new MqttClient($server, $port, $clientId);
$mqtt->connect($connectionSettings, $clean_session);
$mqtt->subscribe('mytopic/respond', function ($topic, $message) use ($mqtt) {
echo $message;
}, 2);
$mqtt->close();
$mqtt->interrupt();
?>
I have 2 computers:
PC 1 - Here is where I installed the XAMPP.
PC 2 - Here is where my database which is Oracle 9i is installed.
I am using PHP 7 and already added PDO_OCI extension.
Here is my connection string:
define("DB_HOST", "192.168.10.30:1521");
define("DB_NAME", "BACKEND");
define("DB_USER", "sa");
define("DB_PASS", "sa_backend");
new PDO('oci:dbname='. DB_NAME . ';host='. DB_HOST .';', DB_USER, DB_PASS);
When I used this code I am getting this error:
Warning: Uncaught PDOException: SQLSTATE[42S02]: pdo_oci_handle_factory: ORA-12154: TNS:could not resolve the connect identifier specified (ext\pdo_oci\oci_driver.c:709)
UPDATE 1
$server = "192.168.10.30";
$db_username = "sa";
$db_password = "sa_backend";
$service_name = "backend";
$sid = "backend";
$port = 1521;
$dbtns = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = $server)(PORT = $port)) (CONNECT_DATA = (SERVICE_NAME = $service_name) (SERVER = SHARED) (SID = $sid)))";
$this->dbh = new PDO("oci:dbname=" . $dbtns . ";charset=utf8", $db_username, $db_password, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC));
I used this code I found on other stackoverflow link. Now I am getting this error
SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12520: TNS:listener could not find available handler for requested type of server (ext\pdo_oci\oci_driver.c:728)
I tried to updated the process to 200 even to 400 but the error is still the same.
I am not succeeding to login into docusign with PHP API. I am getting error
with timeout. But most interestingly I am able to login via REST client
on address with header which is below
https://demo.docusign.net/restapi/v2/login_information
X-DocuSign-Authentication: <DocuSignCredentials><Username>zzzzzzz#yyyy.com</Username><Password>somepasss</Password><IntegratorKey>TEST-xxxxxxxxxxxxxxxxxxxx</IntegratorKey></DocuSignCredentials>Accept: application/json Content-Type: application/json
Does any one have any idea of this error cause? (php configuration, modules extensions? Firewall? geo location restrictions? )
Fatal error: Uncaught exception 'DocuSign\eSign\ApiException' with message 'API call to https://demo.docusign.net/restapi/v2/login_information timed out: a:26:{s:3:"url";s:54:"https://demo.docusign.net/restapi/v2/login_information";s:12:"content_type";N;s:9:"http_code";i:0;s:11:"header_size";i:0;s:12:"request_size";i:0;s:8:"filetime";i:-1;s:17:"ssl_verify_result";i:1;s:14:"redirect_count";i:0;s:10:"total_time";d:0.842999999999999971578290569595992565155029296875;s:15:"namelookup_time";d:0.51500000000000001332267629550187848508358001708984375;s:12:"connect_time";d:0.6870000000000000550670620214077644050121307373046875;s:16:"pretransfer_time";d:0;s:11:"size_upload";d:0;s:13:"size_download";d:0;s:14:"speed_download";d:0;s:12:"speed_upload";d:0;s:23:"download_content_length";d:-1;s:21:"upload_content_length";d:-1;s:18:"starttransfer_time";d:0;s:13:"redirect_time";d:0;s:12:"redirect_url";s:0:"";s:10:"primary_ip";s:14:"162.248.186.25";s:8:"certinfo";a:0:{}s:12:"primary_port";i:443;s:8:"local_ip";s:13:"192.168.1.126";s:10:"local in C:\xampp\htdocs\localbits\ds\docusign\src\ApiClient.php on line 233
( ! ) DocuSign\eSign\ApiException: API call to https://demo.docusign.net/restapi/v2/login_information timed out: a:26:{s:3:"url";s:54:"https://demo.docusign.net/restapi/v2/login_information";s:12:"content_type";N;s:9:"http_code";i:0;s:11:"header_size";i:0;s:12:"request_size";i:0;s:8:"filetime";i:-1;s:17:"ssl_verify_result";i:1;s:14:"redirect_count";i:0;s:10:"total_time";d:0.842999999999999971578290569595992565155029296875;s:15:"namelookup_time";d:0.51500000000000001332267629550187848508358001708984375;s:12:"connect_time";d:0.6870000000000000550670620214077644050121307373046875;s:16:"pretransfer_time";d:0;s:11:"size_upload";d:0;s:13:"size_download";d:0;s:14:"speed_download";d:0;s:12:"speed_upload";d:0;s:23:"download_content_length";d:-1;s:21:"upload_content_length";d:-1;s:18:"starttransfer_time";d:0;s:13:"redirect_time";d:0;s:12:"redirect_url";s:0:"";s:10:"primary_ip";s:14:"162.248.186.25";s:8:"certinfo";a:0:{}s:12:"primary_port";i:443;s:8:"local_ip";s:13:"192.168.1.126";s:10:"local_port";i:38524;} in C:\xampp\htdocs\localbits\ds\docusign\src\ApiClient.php on line 233
and the php code is below:
<?php
require_once('./docusign/autoload.php');
class DocuSignSample
{
public function login()
{
$username = "__some email__";
$password = "__some password___";
$integrator_key = "TEST-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$host = "https://demo.docusign.net/restapi";
$config = new DocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
$apiClient = new DocuSign\eSign\ApiClient($config);
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if (isset($loginInformation) && count($loginInformation) > 0) {
$loginAccount = $loginInformation->getLoginAccounts()[0];
if (isset($loginInformation)) {
$accountId = $loginAccount->getAccountId();
if (!empty($accountId)) {
echo $accountId;
}
}
}
}
}
$dss = new DocuSignSample();
$dss->login();
?>
Try
$config->setSSLVerification(false);
Worked for me.
I was experiencing difficulties to use API up until I found that it is needed to have a signed ssl with http server and php or there is also insecure solution which is simply to disable ssl checking in curl (curl was cause of this inconvenience):
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
I am trying to create mysql database using cpanel xmlapi.
After search on google i found the below code.
$auth_user = 'XXXXXX';
$auth_pass = 'XXXXX';
$server = 'XXXXXXXX.com';
$json_client = new \xmlapi($server);
$json_client->set_output('json');
$json_client->set_port(2083);
$json_client->password_auth($auth_user, $auth_pass);
$json_client->set_debug(1);
# Create Database
$result = $json_client->api1_query($auth_user, 'Mysql', 'adddb',array($shop->alias));
var_dump($result);
After running this code I got this error:
string(202) "{"cpanelresult":{"apiversion":"2","error":"The “cpanel_jsonapi_module†parameter is required.","data":{"reason":"The “cpanel_jsonapi_module†parameter is required.","result":"0"},"type":"text"}}"
I'm getting SMTP ERROR: Failed to connect to server: Connection refused (111) 2015-09-01 13:30:34 SMTP connect() failed when attempting to connect to an Exchange server to send mail with PHPMailer. I don't think it's a problem with the credentials because I used the same credentials to test on pingability.com and I'm able to connect and send without any issues. The openssl extension is enabled as well.
Code I'm using:
require_once 'vendor/PHPMailer/PHPMailerAutoload.php';
$emailer = new PHPMailer();
$emailer->IsSMTP();
$emailer->SMTPDebug = 2;
$emailer->Host = "xxx.xxxxxxx.com";
$emailer->Username = "xxxxx";
$emailer->Password = "xxxxx";
$emailer->Port = 25;
$emailer->isHTML(true);
$emailer->From = "xxx#xxxxxx.com";
$emailer->FromName = 'xxxxxxxxx';
$emailer->Subject = "Reset Your Password";
$emailer->Body = "To reset your password, please visit this link:<br>" . $link;
$emailer->AddAddress( $email );
$emailer->AddAddress( "xxx#xxxxxx.com" );
$emailer->Send();