<?php
$client = new SoapClient("http://localhost/suiteCRM/service/v2/soap.php?wsdl");
$response = $client->__soapCall("login", array(
"user_auth" =>
array(
'user_name' => 'admin',
'password' => md5('223311'),
'version' => "0.1",
),
"application_name"=>""
)
);
$session_id=$response->id;
echo"Session ID".$session_id;
?>
while i connecting it gives 404 error i need solution how to store form values to suitecrm
You should use rest rather than SOAP.
ideally, your URL will be.
http://localhost/suiteCRM/service/v4/rest.php
Related
I am running a PHP 7.3, running on apache server. I used composer to get this library:
https://github.com/SecureTrading/PHP-API
For the code provided, I am now using the test site reference. I already managed to use for regular transitions. I now started managing 3D secure transactions, with the test MAESTRO card provided by secure trading here: https://docs.securetrading.com/document/testing/. the one designed not to demand 3D auth - that is 5000000000000421
The code provided next, will sum up the way I think thought this should work: I start by creating AUTH request, get error 30004, using CACHETOKENISE request to get a token, run THREEDQUERY to figure out if I need a full auth sceme on this card, get N as an answer, and run another AUTH request, this time with the transactionreference.
I am providing a version of the code I am testing (obviously, username, password and site reference name was removed to protect my privacy, but the code otherwise is the same)
<?php
$configData = array(
'username' => 'api#gigsberg.com',
'password' => 'xq!Kq$j4',
);
$site_refrance = 'test_gigsberg74319';
?>
<?php
$configData = array(
'username' => '*****',
'password' => '*****',
);
$site_refrance = '*****';
if (!($autoload = realpath(__DIR__ . '/vendor/autoload.php'))) {
throw new \Exception('Composer autoloader file could not be found.');
}
require_once($autoload);
$api = \Securetrading\api($configData);
$requestData = array(
'sitereference' => $site_refrance,
'requesttypedescription' => 'AUTH',
'accounttypedescription' => 'ECOM',
'currencyiso3a' => 'GBP',
'mainamount' => '1000',
'pan' => '5000000000000421',
'expirymonth' => '12',
'expiryyear' => '2030',
'securitycode' => '123',
);
echo '<pre>';
print_r($requestData);
$response = $api->process($requestData)->toArray();
print_r( $response['responses'] ); // $response['responses'][0]['errorcode'] == 30004
echo "\n--------------------------------------\n";
$transactionreference = $response['responses'][0]['transactionreference'];
$requestData = array(
'sitereference' => $site_refrance,
'expirymonth' => '12',
'expiryyear' => '2030',
'requesttypedescriptions' => array('CACHETOKENISE'),
'securitycode' => '123',
'orderreference' => $transactionreference,
'pan' => '5000000000000421'
);
print_r($requestData);
$response = $api->process($requestData)->toArray();
echo "\n--------------------------------------\n";
$cachetoken = $response['responses'][0]['cachetoken'];
$requestData = array(
'termurl' => 'https://termurl.com',
'accept' => 'text/html,*/*',
'currencyiso3a' => 'GBP',
'requesttypedescription' => 'THREEDQUERY',
'accounttypedescription' => 'ECOM',
'sitereference' => $site_refrance,
'baseamount' => '1000',
'pan' => '5000000000000421',
'expirymonth' => '12',
'expiryyear' => '2030',
'cachetoken' => $cachetoken,
);
print_r($requestData);
$response = $api->process($requestData)->toArray(); // $response['responses'][0]['enrolled'] == 'N'
/* Copying from the docs here: https://docs.securetrading.com/document/api/security/3-d-secure/
* If the enrolled value returned in the response is “Y”, the customer’s card is enrolled in 3-D secure. Please refer to the following table for enrolled values:
* .
* .
* N - The card is not enrolled in the card issuer’s 3-D Secure scheme. - Perform an AUTH Request, including the transactionreference returned in the THREEDQUERY response.
* .
* .
*/
print_r( $response['responses'] );
echo "\n--------------------------------------\n";
$transactionreference = $response['responses'][0]['transactionreference'];
$requestData = array(
'sitereference' => $site_refrance,
'requesttypedescription' => 'AUTH',
'accounttypedescription' => 'ECOM',
'currencyiso3a' => 'GBP',
'mainamount' => '1000',
'pan' => '5000000000000421',
'expirymonth' => '12',
'expiryyear' => '2030',
'securitycode' => '123',
'transactionreference' => $transactionreference
);
print_r($requestData);
$response = $api->process($requestData)->toArray();
print_r( $response['responses'] ); // Still get $response['responses'][0]['errorcode'] == 30004
I expected it to give me a note that all works well, but I still got error 30004, as if the transactionreference wasn't provided. Any idea what I can do, to fix this code, and prevent this error?
Thanks in advance
Yair
Well, I read the Api tests, and I found my error. On the last request data, instead of
$requestData = array(
.
.
'transactionreference' => $transactionreference
.
.
);
I should use
$requestData = array(
.
.
'parenttransactionreference' => $transactionreference
.
.
);
Anyway, home this helps somone
I have been trying to learn how to access the soap services of Web of knowledge using PHP. I am using the code below, which I downloaded from https://gist.github.com/domoritz/2012629.
<?php
$auth_url = "http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl";
$auth_client = #new SoapClient($auth_url);
$auth_response = $auth_client->authenticate();
$search_url = "http://search.isiknowledge.com/esti/wokmws/ws/WokSearchLite?wsdl";
$search_client = #new SoapClient($search_url);
$search_client->__setCookie('SID',$auth_response->return);
$search_array = array(
'queryParameters' => array(
'databaseID' => 'WOS',
'userQuery' => 'AU=Douglas T*',
'editions' => array(
array('collection' => 'WOS', 'edition' => 'SSCI'),
array('collection' => 'WOS', 'edition' => 'SCI')
),
'queryLanguage' => 'en'
),
'retrieveParameters' => array(
'count' => '5',
'fields' => array(
array('name' => 'Date', 'sort' => 'D')
),
'firstRecord' => '1'
)
);
try{
$search_response = $search_client->search($search_array);
} catch (Exception $e) {
echo $e->getMessage();
}
print_r($search_response);
?>
The code seems to be working. However, the $search_response I receive is
"User has no entitlement for this service level - WOKSearchLight". I am trying to access this piece of data from a server that is inside an institution that has access to the web of knowledge, and I am actually connected to web of knowledge using http://apps.webofknowledge.com/UA_GeneralSearch_input.do?product=UA&search_mode=GeneralSearch&SID=4Dd8nnfofoOm#7#5KH6&preferencesSaved=.
Can anyone tell me what is happening? Do I need an extra permission of the site?
I really appreciate any help!
Yes you need to register first at http://ip-science.thomsonreuters.com/info/ws_form/?agree=0&x=31&y=12 and enter your IP address, then it should work I think...
I am really stuck in this, and need expert help. Let me explain what I am trying achieve and the setup. I had a script which posts over a https form using Zend_Http_Client. On the server setup I have tor & privoxy running. Everything just worked fine, but now I need to make the code more scalable by running multiple instances of tor & privoxy on the same server.
Hence I shifted the Adapter for Zend from Zend_Http_Client_Adapter_Curl to Zend_Http_Client_Adapter_Proxy . But after changing the adapter I have bumped into a strange error which says - 400 Invalid header received from client and when I dump the object of Zend client, I see the following -
MyWebClientResponse::__set_state(array(
'json' => NULL,
'version' => '1.1',
'code' => 400,
'message' => 'Invalid header received from client',
'headers' =>
array (
'Proxy-agent' => 'Privoxy 3.0.19',
'Content-type' => 'text/plain',
'Connection' => 'close',
),
'body' => 'Invalid header received from client.
',
))
I do not understand what is that I am doing wrong. The code is done in Yii Framework so it is hard to share all the classes and Models, but I am sharing the main parts of the code, which are responsible for this -
$client = MyWebClient::factory();
$adapter = $client->getAdapter();
$adapter->setConfig(array('timeout' => 120,
'proxy_host' => 'localhost',
'proxy_port' => 8124
));
$client->setAdapter($adapter);
$client->setCookieJar(true);
$client->setParameterPost(array(
'name' => 'firstname',
'password' => 'password,
'login' => 'home'
));
$response = $client->setUri('https://www.domain.com/post.php')->requestApi('POST', false);
Here's the constructor of the class MyWebClient, just in case it it required, all other methods are standard.
static public function factory($new = false)
{
if (!isset(self::$client))
{
self::$client = new MyWebClient();
self::$client->setConfig(array(
'adapter' => 'Zend_Http_Client_Adapter_Proxy',
// 'proxy_host' => 'localhost',
// 'proxy_port' => 8118,
'persistent' => false,
'timeout' => 120
));
}
return self::$client;
}
The headers are being set in the requestAPI method and the snippet is -
$headers = array(
'X-PHX' => 'true',
'X-Requested-With' => 'XMLHttpRequest',
'Referer' => 'https://domain.com/index.html',
'User-Agent' => self::getRandomUserAgent()
);
$this->setHeaders($headers);
I would really appreciate help in this regard. Think it's privoxy which is not letting go the request out of the server.
Sachin
Looks like you may need to wrap the user-agent with quotes. Try this when setting the headers and see if that fixes the problem.
$headers = array(
'X-PHX' => 'true',
'X-Requested-With' => 'XMLHttpRequest',
'Referer' => 'https://domain.com/index.html',
'User-Agent' => "'".self::getRandomUserAgent()."'"
);
$this->setHeaders($headers);
Finally I decided to use the native cURL library and the cookieJar which comes with it. It worked like expected.
Cheers,
Sachin
I'm having issues attempting to pull up tracking info using Fedex's Web Services. I am using a valid tracking number and I'm able to view the details on Fedex's site. However, I get an error 9040 "No information for the following shipments has been received by our system yet. Please try again or contact Customer Service at 1.800.Go.FedEx(R) 800.463.3339." Am I leaving something out?
My code:
<?php
$path_to_wsdl = "URL_TO_WSDL";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
$request['WebAuthenticationDetail'] = array(
'UserCredential' =>array(
'Key' => 'MY_KEY',
'Password' => 'MY_PASSWORD'
)
);
$request['ClientDetail'] = array(
'AccountNumber' => 'MY_ACCT',
'MeterNumber' => 'MY_METER'
);
$request['TransactionDetail'] = array('CustomerTransactionId' => 'ActiveShipping');
$request['Version'] = array(
'ServiceId' => 'trck',
'Major' => '5',
'Intermediate' => '0',
'Minor' => '0'
);
$request['PackageIdentifier'] = array(
'Value' => 'TRACKING#',
'Type' => 'TRACKING_NUMBER_OR_DOORTAG');
$response = $client->track($request);
var_dump($response);
?>
Got it!
Call the web services departement and they told me to remove 'beta' from the wsdl file. This appears to be a different address than what I found in responses to this problem before. On line 1507 of the wsdl file, make the following change:
From:
<s1:address location="https://wsbeta.fedex.com:443/web-services/track"/>
To
<s1:address location="https://ws.fedex.com:443/web-services/track"/>
I changed the rest of my code slightly, but that shouldn't have made the difference. To be on the safe side, here it is:
<?php
$path_to_wsdl = "PATH_TO_WSDL_FILE";
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
$trackRequest = array(
'WebAuthenticationDetail' => array(
'UserCredential' => array(
'Key' => 'MY_KEY',
'Password' => 'MY_PASSWORD'
)
),
'ClientDetail' => array(
'AccountNumber' => 'MY_ACCT_#',
'MeterNumber' => 'MY_METER_#'
),
'Version' => array(
'ServiceId' => 'trck',
'Major' => '5',
'Intermediate' => '0',
'Minor' => '0'
),
'PackageIdentifier' => array(
'Type' => 'TRACKING_NUMBER_OR_DOORTAG',
'Value' => 'THE_TRACKING_#',
),
'CustomerTrasactionId',
'IncludeDetailedScans' => 1
);
$response = $client->track($trackRequest);
var_dump($response);
?>
I'm also working on this same problem. I'm trying several things and you can see if anything works for you. Try including ShipDateRangeBegin and End elements, your test account/payer numbers or destination info. I've found here that switching to xml and ssl post requests supposedly solve the problem, but it's not an option for me. Maybe it will help you?
I have same problem when use xml-request. I solved the problem this way:
$endpointurl = "https://gatewaybeta.fedex.com:443/xml"; // remove word "beta"
$endpointurl = "https://gateway.fedex.com:443/xml";
...
$request = stream_context_create($form);
$browser = fopen($endpointurl , 'rb' , false , $request);
$response = stream_get_contents($browser);
...
I'm having a recurring issue with PHP's inbuilt SOAP client where it returns the same error response regardless of the input paramaters.
Is there an advantage to using the SOAP library built into PHP or a disadvantage to directly querying via cURL through GET?
$client = new SoapClient("http://example.com/wdsl");
$params = array(
'Username' => 'username',
'Password' => 'pass',
'EventName' => 'Test Event',
'EventDate' => '2011-06-15T13:45:30',
'Destination' => '447987654321',
'Carrier' => '1',
'PhoneType' => '13',
'Originator' => 'ukflive',
'MessageText' => 'Test',
'LogoURL' => 'http://example.com/mail.gif',
'BookingReference' => '123456',
'Tickets' => '1',
'CollectionValidFrom' => '2011-06-15T13:45:30',
'CollectionValidTo' => '2011-06-15T18:45:30',
'TemplatePath' => '',
'PostBack' => 'http://example.com/'
);
$response = $client->__soapCall("SendManagedMobileTicket", $params);
print_r($response);
SoapClient is an integrated, actively maintained part of PHP5. cURL is the quick and dirty way to send HTTP data. The smart long term decision is to stick with SoapClient and its methods.
You may also want to look into the response headers, as shown in the notes section of the __soapCall() documentation page: http://www.php.net/manual/en/soapclient.soapcall.php#102387