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

Support Yandex Direct api and example #89

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ NuSOAP is a rewrite of SOAPx4, provided by NuSphere and Dietrich Ayala. It is a

## Info

- Supported PHP: [5.4 - 8.1](https://travis-ci.org/pwnlabs/nusoap)
- Latest version: [0.9.11](https://github.com/pwnlabs/nusoap/releases/tag/v0.9.11)
- Dev version: [develop](https://github.com/pwnlabs/nusoap/tree/develop)
- [Supported PHP: 7.3 - 8.1](https://travis-ci.org/pwnlabs/nusoap)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change readme? Can you put it back? :-)

- [Latest release: 0.9.11](https://github.com/pwnlabs/nusoap/releases/tag/v0.9.11)
- [Dev version: develop](https://github.com/pwnlabs/nusoap/tree/develop)
- Official project: https://sourceforge.net/projects/nusoap/
- [smevx-crypto for Java 8](https://github.com/proxy-m/smevx-crypto)
- [openssl error: Algorithm gost2012_256 not found](https://forum.rutoken.ru/topic/3173/)
- [openssl gost2012_256, hmac-gost-3411-12-256](https://docs.altlinux.org/ru-RU/alt-workstation/10.1/html-single/alt-workstation/index.html#idm45860460701600)

## Installation

Expand Down
30 changes: 30 additions & 0 deletions samples/client4yandex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
require_once('./lib/nusoap.php');

$wsdlurl = 'https://api-sandbox.direct.yandex.com/v5/campaigns?wsdl'; /// 'https://api-sandbox.direct.yandex.ru/live/v4/wsdl/';
$token = 'YOUR TOKEN';
$locale = 'en';

// Initialization of NuSOAP-client
$client = new nusoap_client($wsdlurl, 'wsdl');

# Parameters of NuSOAP-client
$client->authtype = 'bearer'; /// 'basic';
$client->decode_utf8 = 0;
$client->soap_defencoding = 'UTF-8';

// Adding headers for SOAP-request
$client->setCredentials('token', $token, 'bearer'); ///$client->setHeaders("<token>$token</token>\n <locale>$locale</locale>");

// Call request to server (API Yandex Direct)
$result = $client->call(/*'GetClientInfo'*/'get', array('SelectionCriteria' => (object) array(), 'FieldNames' => array('Id', 'Name')));

// Output of request and response
echo "Request (to server):<pre>".htmlspecialchars($client->request, ENT_QUOTES)."</pre>";
echo "Response (from server):<pre>".htmlspecialchars($client->response, ENT_QUOTES)."</pre>";


// Output of debug info
echo '<hr><pre>'.htmlspecialchars($client->debug_str, ENT_QUOTES).'</pre>';

?>
14 changes: 11 additions & 3 deletions src/nusoap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2546,8 +2546,14 @@ function connect($connection_timeout = 0, $response_timeout = 30)
$this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
}

if ($this->scheme == 'https') {
if ($this->scheme == 'https') {
$this->setCurlOption(CURLOPT_SSLENGINE, 'gost');
$this->setCurlOption(CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_1); // TLSv1.1 and more (TLSv1.1, TLSv1.2, TLSv1.3)
///$this->setCurlOption(CURLOPT_SSL_CIPHER_LIST, 'TLSv1,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES128-SHA');
///$this->setCurlOption(CURLOPT_TLS13_CIPHERS, 'GOST2012-GOST8912-GOST8912:GOST2001-GOST89-GOST89:DES-CBC3-SHA:IDEA-CBC-MD5:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-DSS-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDH-RSA-AES256-GCM-SHA384:ECDH-ECDSA-AES256-GCM-SHA384:AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDH-RSA-AES128-GCM-SHA256:ECDH-ECDSA-AES128-GCM-SHA256:AES128-GCM-SHA256:TLS_AES_256_GCM_SHA384'); /////
$this->debug('set cURL SSL verify options');
///$this->setCurlOption(CURLOPT_SSLCERTTYPE, 'CERT_SHA1_HASH_PROP_ID:CERT_SYSTEM_STORE_CURRENT_USER:MY');
///$this->setCurlOption(CURLOPT_SSLCERT, '53be6850031bf03bff056fd5215a46c07b2248d6');
// recent versions of cURL turn on peer/host checking by default,
// while PHP binaries are not compiled with a default location for the
// CA cert bundle, so disable peer/host checking.
Expand Down Expand Up @@ -2692,7 +2698,7 @@ function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies = NULL)
*
* @param string $username
* @param string $password
* @param string $authtype (basic|digest|certificate|ntlm)
* @param string $authtype (basic|bearer|digest|certificate|ntlm)
* @param array $digestRequest (keys must be nonce, nc, realm, qop)
* @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
* @access public
Expand All @@ -2706,6 +2712,8 @@ function setCredentials($username, $password, $authtype = 'basic', $digestReques
// cf. RFC 2617
if ($authtype == 'basic') {
$this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password));
} elseif ($authtype == 'bearer') {
$this->setHeader('Authorization', 'Bearer ' . (isset($password) ? $password : $username));
} elseif ($authtype == 'digest') {
if (isset($digestRequest['nonce'])) {
$digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
Expand Down Expand Up @@ -3001,7 +3009,7 @@ function sendRequest($data, $cookies = null)
//$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
$curl_headers = array();
foreach ($this->outgoing_headers as $k => $v) {
if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || /*$k == 'Authorization' ||*/ $k == 'Proxy-Authorization') {
$this->debug("Skip cURL header $k: $v");
} else {
$curl_headers[] = "$k: $v";
Expand Down