Does not work creation an envelope through Docusign SDK PHP - php

Using the example of CreateEnvelope sample code
I receive a message:
Guid should contain 32 digits with 4 dashes
(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
Using the method of guid() of SDK, which returns a string in the form {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
I receive a message:
The 'http://www.docusign.net/API/3.0:ID' element is invalid - The
value '0 'is invalid according to its datatype
What is the format for the recipient ID is valid?

In DocuSign, when you are adding recipients to your envelopes you need at least 3 pieces of data to uniquely identify each recipient. You need to set recipient name, email, and recipientId. (If you are using the Embedding feature then you need to set the CaptiveInfo as well for SOAP or the clientUserId if using REST)
The recipientId is user-defined, meaning you can set it to whatever you like- however it needs to be a non-negative number such as 1, 2, 1000, 2000. I believe the data type for the recipientId is string so you're not limited to just numbers either.
However, 0 is the one value that you can not set it to. So try changing the value of your recipientId to 1 or 2 or one or two or 1abc or 2def and see if that resolves your issue.

I use the following code:
$r = new Recipient();
$r->ID = '1';
$r->UserName = 'john';
$r->SignerName = 'John Doe';
$r->Email = 'john#example.com';
$r->Type = RecipientTypeCode::Signer;
$r->RoutingOrder = 1;
$r->RequireIDLookup = false;
$r->CaptiveInfo = new RecipientCaptiveInfo();
$r->CaptiveInfo->ClientUserId = '1';
...
And getting an error message:
Uncaught SoapFault exception: [soap:Client] 358101: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
If I use the following code:
$uid = $this->getUid();
$r->ID = $uid;
...
$r->CaptiveInfo->ClientUserId = $uid;
...
$this->getUid() using the method of guid() of SDK, which returns a string in the form {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
Getting an error message:
Uncaught SoapFault exception: [soap:Client] Validation error: The 'http://www.docusign.net/API/3.0:ID' element is invalid - The value '0' is invalid according to its datatype 'http://www.docusign.net/API/3.0:LocalId' - Value '0' was either too large or too small for PositiveInteger.

Related

Telegram bot doesnt answer

This is code of my bot in PHP, but it doesnt answer. What should I do? Here's the PHP error log :
[24-Sep-2018 09:06:29 UTC] PHP Warning: file_get_contents(https://api.telegram.org/bot694EMvJayx1zD-J3FPyKPfRlGka0 /sendMessage?chat_id=110***01&text=hellhAkbarixyzhMohammad Hosein): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
in /home/xcqcctmm/public_html/BOT/getnewsir.php on line 22
The code is :
<?php
$token = '692******1zD-J3FPyKPfRlGka0';
// read incoming info and grab the chatID
$json = file_get_contents('php://input');
$telegram = urldecode ($json);
$results = json_decode($telegram);
$message = $results->message;
$text = $message->text;
$chat = $message->chat;
$user_id = $chat->id;
$username = $chat->username;
$first_name = $chat->first_name;
//send reply
$answer = "hello".$user_id . "h" . $username . "h" . $first_name;
$url = 'https://api.telegram.org/bot'.$token.'/sendMessage?chat_id='. $user_id .'&text='.$answer;
file_get_contents($url);
?>
it doesn't work.
Telegram's API returns 400 Bad Request, which could be caused by any of the following:
FIRSTNAME_INVALID: The first name is invalid
LASTNAME_INVALID: The last name is invalid
PHONE_NUMBER_INVALID: The phone number is invalid
PHONE_CODE_HASH_EMPTY: phone_code_hash is missing
PHONE_CODE_EMPTY: phone_code is missing
PHONE_CODE_EXPIRED: The confirmation code has expired
API_ID_INVALID: The api_id/api_hash combination is invalid
PHONE_NUMBER_OCCUPIED: The phone number is already in use
PHONE_NUMBER_UNOCCUPIED: The phone number is not yet being used
USERS_TOO_FEW: Not enough users (to create a chat, for example)
USERS_TOO_MUCH: The maximum number of users has been exceeded (to create a chat, for example)
TYPE_CONSTRUCTOR_INVALID: The type constructor is invalid
FILE_PART_INVALID: The file part number is invalid
FILE_PARTS_INVALID: The number of file parts is invalid
FILE_PART_Х_MISSING: Part X (where X is a number) of the file is missing from storage
MD5_CHECKSUM_INVALID: The MD5 checksums do not match
PHOTO_INVALID_DIMENSIONS: The photo dimensions are invalid
FIELD_NAME_INVALID: The field with the name FIELD_NAME is invalid
FIELD_NAME_EMPTY: The field with the name FIELD_NAME is missing
MSG_WAIT_FAILED: A waiting call returned an error
Unfortunately, you have to debug which one causing the actual error.
Source

SOAP API / SQL Error "ORA 00904 invalid Identifier"

I have the following problem:
I need to get a few columns of a oracle db table to display information on a .php page. To do this, I'm using a SOAP-API, which works flawlessly with any other table, only not with this one.
This is the Code I am using for all of these Queries:
$setSearchObjectsIn = new SearchObjectsInType();
$setSearchObjectsIn->sessionId = (String) $sessionId;
$setSearchObjectsIn->table = (String) 'STFCFG_DD_VALUE';
$setSearchObjectsIn->caseSensitive = (String) 'false';
$setSearchObjectsIn->limitedResult = (String) 'false';
$setSearchObjectsIn->restrictions[0]['attributeName']= (String) 'STFCFG_DD_VALUE.DDID';
$setSearchObjectsIn->restrictions[0]['restriction']['operator'] = (String) '=';
$setSearchObjectsIn->restrictions[0]['restriction']['value'] = (String) $ddid;
$setSearchObjectsIn->resultColumns[0] = (String) 'STFCFG_DD_VALUE.DD_VALUE';
$setSearchObjectsIn->resultColumns[1] = (String) 'STFCFG_DD_VALUE.CATALOG_NAME';
$setSearchObjectsIn->resultColumns[2] = (String) 'STFCFG_DD_VALUE.MSG_ID';
$client = new SoapClient((String) $instance.'/axis/services/GenericApiWS?wsdl');
$result = $client->searchObjects($setSearchObjectsIn);
And this is the Error I get with this special table:
ORA-00904: "MAN_ID": ungültiger Bezeichner
I have also tried starting this query with SoapUI, which results in the exactly same thing.
The fact, that I have nothing like "MAN_ID" in my code has me wondering, as the error looks like I would query a column named like that, which I obviously don't do. (There is also no column "MAN_ID" in the requested table, so I have no idea where this comes from)
I hope you can help me
I'd try looking for MAN_ID in the SOAP server code - the error may be what the server returns and it may be looking for that column implicitly. The error message is definitely produced by Oracle, so search the way your query gets there and if possible, see what query gets executed.

Get token balance with Ethereum RPC?

how display balance of token through Ethereum RPC?
$id = 0;
$data = array();
$data['jsonrpc'] = '2.0';
$data['id'] = $id++;
$data['method'] = 'eth_call';
$data['params'] = [['from' => '0x0...', 'to' => '0x0...', 'data' => 'contract byte code here 0x0...'], 'latest'];
$ch = curl_init();
...
Return:
{"jsonrpc":"2.0","id":0,"result":"0x"}
What to do next? Call contract method balanceOf? How to do that?
To get token balance with eth_call you need to and data parameter. to is contract address, here we need to generate the data parameter. As the doc eth_call says,
data: DATA - (optional) Hash of the method signature and encoded
parameters. For details see Ethereum-Contract-ABI
Take this EOS token transaction as a example.
Contract address:0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0
Token Holder address:0x0b88516a6d22bf8e0d3657effbd41577c5fd4cb7
You can see the contract code here.
contract ERC20 {
function totalSupply() constant returns (uint supply);
function balanceOf( address who ) constant returns (uint value);
function allowance( address owner, address spender ) constant returns (uint _allowance);
function transfer( address to, uint value) returns (bool ok);
function transferFrom( address from, address to, uint value) returns (bool ok);
function approve( address spender, uint value ) returns (bool ok);
event Transfer( address indexed from, address indexed to, uint value);
event Approval( address indexed owner, address indexed spender, uint value);
}
Function Selector
>>> from web3 import Web3
>>> Web3.sha3("balanceOf(address)")
HexBytes('0x70a08231b98ef4ca268c9cc3f6b4590e4bfec28280db06bb5d45e689f2a360be')
Take the first four bytes 70a08231
Argument Encoding
address: equivalent to uint160, except for the assumed interpretation
and language typing.
int: enc(X) is the big-endian two's complement encoding of X,
padded on the higher-order (left) side with 0xff for negative X and
with zero bytes for positive X such that the length is a multiple of
32 bytes.
Padding the 20 bytes token address to 32 bytes with 0 to token holder address:
0000000000000000000000000b88516a6d22bf8e0d3657effbd41577c5fd4cb7
Then concat the function selector and encoded parameter, we get data parameter:
0x70a082310000000000000000000000000b88516a6d22bf8e0d3657effbd41577c5fd4cb7
Make the request with:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to": "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0", "data":"0x70a082310000000000000000000000000b88516a6d22bf8e0d3657effbd41577c5fd4cb7"}, "latest"],"id":67}' -H "Content-Type: application/json" http://127.0.0.1:8545/
here is the curl result (You may get different answer here, as there may be some transaction with this address done after my polling the request)
{"jsonrpc":"2.0","id":67,"result":"0x00000000000000000000000000000000000000000000014a314d9ff9b20b9800"}
You can change convert hex format balance to decimal
>>> 0x00000000000000000000000000000000000000000000014a314d9ff9b20b9800
6090978215900000000000
Check the result,
When calling a Solidity contract function, in general, data should be the following, encoded as a hex string:
The "function selector," which is the first four bytes of the keccak-256 hash of the signature of the function you're calling.
The ABI-encoded arguments to the function you're calling.
The function signature for an ERC20 token's balanceOf is balanceOf(address). The keccak-256 hash is 70a08231b98ef4ca268c9cc3f6b4590e4bfec28280db06bb5d45e689f2a360be, so the first four bytes are 70a08231.
The function only takes a single parameter: the address of the account whose balance you're trying to look up. To ABI-encode it, simply left-pad it with zeros until it's 32 bytes long. Since addresses are 20 bytes, this means adding 12 bytes of zeros (or 24 characters in hex).
So the full data field should be "0x70a08231" + "000000000000000000000000" + address.
May I recommend a proper ERC20 library for PHP that I have developed myself.
https://www.furqansiddiqui.com/libraries/erc20-php/
https://github.com/furqansiddiqui/erc20-php
sample code to retrieve balance:
<?php
$geth = new EthereumRPC('127.0.0.1', 8545);
$erc20 = new \ERC20\ERC20($geth);
// Pass ERC20 contract address as argument below
$token = $erc20->token('0xd26114cd6EE289AccF82350c8d8487fedB8A0C07');
var_dump($token->name()); # string(8) "OMGToken"
var_dump($token->symbol()); # string(3) "OMG"
var_dump($token->decimals()); # int(18)
var_dump($token->balanceOf('0x...')); // Enter ethereum address here
For token transaction you need to use eth_sendTransaction.

SOAP-ERROR: When using Enterprise Client for SalesForce

I am attempting to pass a custom field via a SOAP Client to SalesForce, here's my existing code:
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
$leadConvert = new stdClass;
$leadConvert->leadId = $eLEADID;
$leadConvert->Custome_field = true;
$leadConvertArray = array($leadConvert);
echo "<pre>";
print_r($leadConvertArray);
echo "</pre>";
$leadConvertResponse = $mySforceConnection->convertLead($leadConvertArray);
echo "<pre>";
print_r($leadConvertResponse);
echo "</pre>";
}
catch (Exception $e) {
echo $e->faultstring;
}
The way it's being passed to SOAP is this:
Array
(
[0] => stdClass Object
(
[leadId] => XXXXXXXXXX
[Custom_field] => 1
)
)
And my error that I am getting is as follows:
SOAP-ERROR: Encoding: object has no 'convertedStatus' property
Do I have to set something in the WSDL in order for this to work? This is to attempt to update a leadID in SalesForce to have it be converted to account/opportunity.
Is there a better way for me to debug this and see what I am missing maybe from the WSDL?
Note: the error means that you "literally" don't have the parameter set in the request. To fix it, simply pass what it's complaining about.
New Issue:
After adding the request, I am getting the following error:
Element {urn:enterprise.soap.sforce.com}Custome_field invalid at this location
Not quite sure what that error means at all. Any thoughts?
For the error:
Element {urn:enterprise.soap.sforce.com}Custome_field invalid at this location
It appears you are trying to set a custom field on the Lead record to a boolean value.
Custom fields in Salesforce will typically end with the __c suffix.
Check the API name for the field in Salesforce and ensure the user who generated and is accessing the Enterprise API has field level access to it.
Then you code should be something like:
$leadConvert->Custom_field__c = true;
It also seems a bit odd that you are setting a custom field for a Lead and then passing it to the convertLead() web method. See the LeadConvert Arguments, which include convertedStatus.

Why php's soapCall gives string conversion error?

// Set username and password
$ih_soap_user= $this->config->item('interUser');
$ih_soap_pass=$this->config->item('interPass');
//echo $ih_soap_user.':P:'.$ih_soap_pass;
// Set soap namespace
$ih_soap_ns = 'http://www.interhome.com/webservice';
// Create new instance of SoapClient with the interhome web service URL
$client = new
SoapClient($this->config->item('interSoap'),array('trace'=>'1'));
// Create new soap header and set username and password
$header = new SoapHeader($ih_soap_ns,
'ServiceAuthHeader',
array('Username' => $ih_soap_user,'Password' =>
$ih_soap_pass),
true
);
// Prepare p// Prepare parameters
$params = array('inputValue' =>array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>array('House'=>'House'),
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'',
) );
try{
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
Hi guys..Any Idea why this call when I pass any not empty array, as for example ,as I made for 'HouseApartmentType', returns this error
A PHP Error was encountered
Severity: Notice Message:
Array to string conversion
Filename:
controllers/houses.php Line
Number: 269
And when it's only empty array or a string the soap call function is working... I need to pass array of options to one parameter....
LINE 269 is
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
This is probably solved already, but I also had problems with this and I thought I should post here when I finally found the solution. (The solution is not nusoap, it throws the same error.)
The error only seems to come from the soapCall call generation, it really is the Web Service that causes it. When you run __soapCall, it first asks the server which datatypes the parameters should have and then tries to comply. So if you try to feed an array when the service expects a string, it will do the array to string conversion when the request is generated.
i think you should look at the manual how a soapcall work:
$params = array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>'House', // changed to string instead of array
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'' );
i simplified the array and you should test it and look if this is the kind of result you are looking for.
Also look for ordering errors like the example shown in php.net

Categories