I Have a function that i want to use it in web-service ... for wsdl and nusoap
another users that connect to me with php havent any problem on nusoap .but whos connect me with asp can add my web-service and see my 2 classes for example enqueue and get credit but cant work with this 2 method ... i didnt work with asp.....
here is my functions and my web-service how i change this files to whos work with asp can connect to me and where is the problem
here is my index.php
<?php header('Content-Type: text/xml');
require(dirname(__FILE__).'/gw.interface.php');
$server = new SoapServer('gw.wsdl', array('uri' => 'uri:SMSServer','encoding'=>'UTF-8'));
$server->setClass("gwi");
$server->handle();
// i think here i must register my functions??
?>
and here is my functions in gw.interface.php
public static function getstatus(&$batchid, &$unique_id)
{
$uname = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if(!isset($_SERVER['PHP_AUTH_USER']) || !db::exists('`users`', '`uname`="'.$uname.'" AND `upass`="'.$pass.'"'))
{
return array('state' => 'error', 'message' => 'Username or/and Password doesnt match.', 'errnum' => '102', 'cost' => '-1', 'msgid' => '-1');
}
$number = sms_send::number_info($uname, $from);
db::update('`users`', '`sents`=`sents`+1', '`uname`="'.$uname.'"');
$gate = SMSGate($number['gateway'], $number['gwuname'], $number['gwpass'], $number['company']);
$sents = sms_send::get_sents($msg_id);
if($sents[0]['state'] == 'working')
{
return array('state' => 'error', 'message' => 'Message is still in sending procces, try after the proccess is done.', 'errnum' => '107', 'rcpts' => array());
}
$sent_rcpts = sms_send::get_sent_rcpts($msg_id, $sents[0]['batchid']);
return array('state' => 'done', 'message' => 'Each recieptor\'s state fetched successfully.', 'errnum' => '100', 'rcpts' => $sent_rcpts);
}
Related
I am sending post requests in PHP to get a boolean value from my API (so it should return wither true or false)
This is the code I am using in the file for my API. The file is called users.php
if ($_POST['type'] == "authenticateMinecraft"){
$p = new dibdibs\post(
array(
'url' => 'https://authserver.mojang.com/authenticate',
'data' => array(
'agent' => array(
'name' => 'Minecraft',
'version' => 1
),
'username' => $_POST['username'],
'password' => $_POST['password'],
'clientToken' => "33225A179D9A4E1BDA73C012C1C3CBAB8BD00326883BDBEB6FA682482E40F68D"
)
)
);
$res = $p->json();
if (isset($res["selectedProfile"])){
echo("true");
}
else{
echo("false");
}
}
This is the code I am using to reference it (I am using a class which I have put on Pastebin to actually send the request).
$params = array(
'data' => array(
'type' => 'authenticateMinecraft',
'username' => $mcuname,
'password' => $mcpasswd
),
'url' => "api/users.php"
);
$c = new dibdibs\post($params);
$r = $c->http();
var_dump($r);
Whenever I use the .php fule extension when defining url, the whole PHP code of the API page is returned, but when I remove the extension, only true or false is returned. Why is this and is it a problem that I should be aware of and I should fox?
I am using web services to get the parameter from SOAP client successfully. I want to pass this parameters in url through html form so that i can connect to my system with this parameters. I have 2 functions. Function login() is to set the parameters for the connection from SOAP client and function getVehicle() to get this parameters. In getVehicle() i want to send the parameters user, hash password, dealer_number, corporate_group_id to client.php from url. And this parameters i want to send from form action without submit button.
index.php
function login()
{
$wsdl = 'http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl';
$options = array('trace' => true);
$params = array(
'user' => utf8_encode('deshmukh'),
'password' => utf8_encode('deshmukh'),
'corporate_group_id' => '101',
'dealer_number' => 'INT31303',
'dms_id' => 'A13T2D19',
'dms_image_url' => '',
'dms_keepalive_url' => '',
'dms_followup_url' => ''
);
$client = new SoapClient($wsdl, $options);
$result = $client->Login($params);
return $return;
}
if($parameter['aktion'] == 'getVehicle')
{
//var_dump(Login());
$vehicle=login();
$user_login=$vehicle['user'];
$password=$vehicle['password'];
$dealer_no=$vehicle['dealer_number'];
$group_id=$vehicle['corporate_group_id'];
//form action here
}
You can have the data transferred to your client.php as a GET request using the built-in php function file_get_contents() like this:
if ($parameter['aktion'] == 'getVehicle')
{
$vehicle=login();
$user_login=$vehicle['user'];
$password=$vehicle['password'];
$dealer_no=$vehicle['dealer_number'];
$group_id=$vehicle['corporate_group_id'];
// send the data to your system
$system_url = 'http://yoursite.com/path/to/client.php';
header("Location: $system_url?user=$user_login&password=$password&dealer_number=$dealer_no&corporate_group_id=$group_id");
exit();
}
If you want, you can have client.php reurn a "success" or "error" output and you'll have it on the $response variable and you can log it or do something else with it.
In your login() you are returning $return, that is wrong. You need to return $result, which is holding the result from curl request.
function login()
{
$wsdl = 'http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl';
$options = array('trace' => true);
$params = array(
'user' => utf8_encode('deshmukh'),
'password' => utf8_encode('deshmukh'),
'corporate_group_id' => '101',
'dealer_number' => 'INT31303',
'dms_id' => 'A13T2D19',
'dms_image_url' => '',
'dms_keepalive_url' => '',
'dms_followup_url' => ''
);
$client = new SoapClient($wsdl, $options);
$result = $client->Login($params);
return $result;
}
if($parameter['aktion'] == 'getVehicle')
{
$vehicle=login();
var_dump($vehicle);
}
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'm using Joomla with PHP, there is one component(payplans) is available for Joomla. In that component they configured lot of payment methods, including Authorize.net. We can select the payment method in the Joomla back-end, our client using Authorize.net so we selected Authorize.net.I did not change anything in the code, its working in our local m/c. I'm getting error only in live server even i have put the live account details not test account.
protected function _processNonRecurringRequest(PayplansPayment $payment, $data)
{
$transactionData = array(
'amount' => $payment->getAmount(),
'card_num' => $data['x_card_num'],
'exp_date' => $data['x_exp_date'],
'first_name' => $data['x_first_name'],
'last_name' => $data['x_last_name'],
'address' => $data['x_address'],
'city' => $data['x_city'],
'state' => $data['x_state'],
'country' => $data['x_country'],
'zip' => $data['x_zip'],
'email' => $data['x_email'],
'card_code' => $data['x_card_code'],
'ship_to_first_name' => $data['x_ship_to_first_name'],
'ship_to_last_name' => $data['x_ship_to_last_name'],
'ship_to_address' => $data['x_ship_to_address'],
'ship_to_city' => $data['x_ship_to_city'],
'ship_to_state' => $data['x_ship_to_state'],
'ship_to_zip' => $data['x_ship_to_zip'],
'ship_to_country' => $data['x_ship_to_country']
);
// echo "Data \n";
$transaction = new AuthorizeNetAIM();
$transaction->setSandbox(true);
$transaction->setFields($transactionData);
// print_r($transaction); exit();
// echo "response";
$response = $transaction->authorizeAndCapture();
// print_r($response);exit();
$transactionArray = $response->toArray();
// to identify it sis testing mode or not
$transactionArray['testmode'] = $this->getAppParam('sandbox', 0);
// save transaction notification and transaction id
if(isset($transactionArray['transaction_id'])){
$payment->set('txn_id', $this->getId().'_'.$transactionArray['transaction_id']);
}
$payment->set('transaction',PayplansHelperParam::arrayToIni($transactionArray));
$errors = array();
if($response->approved){
$payment->set('status',XiStatus::PAYMENT_COMPLETE);
}
else{
$payment->set('status',XiStatus::PAYMENT_PENDING);
$errors['response_reason_code'] = $response->response_reason_code;
$errors['response_code'] = $response->response_code;
$errors['response_reason_text'] = $response->response_reason_text;
}
return $errors;
}
I got error in this line
$response = $transaction->authorizeAndCapture();
please help
You have the following set to True:
$transaction->setSandbox(true);
Surely it should be set to false for the live server environment.
I downloaded the sample code to request a rate from fedex's website... i placed the WSDL file in the proper location, I have my acct number, password, meter number, and key. When I run the script I get this error:
Error in processing transaction.
ERROR
prof
1000
Authentication Failed
The script they give is as follows, and yes i do actually replace the XXX and YYY everywhere it says.:
<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 7.0.0
require_once('fedex-common.php5');
$newline = "<br />";
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "RateService_v7.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array('UserCredential' =>
array('Key' => 'XXX', 'Password' => 'YYY')); // Replace 'XXX' and 'YYY' with FedEx provided credentials
$request['ClientDetail'] = array('AccountNumber' => 'XXX', 'MeterNumber' => 'YYY');// Replace 'XXX' with your account and meter number
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v7 using PHP ***');
$request['Version'] = array('ServiceId' => 'crs', 'Major' => '7', 'Intermediate' => '0', 'Minor' => '0');
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
$request['RequestedShipment']['ServiceType'] = 'FEDEX_GROUND'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['Shipper'] = array('Address' => array(
'StreetLines' => array('10 Fed Ex Pkwy'), // Origin details
'City' => 'Memphis',
'StateOrProvinceCode' => 'TN',
'PostalCode' => '38115',
'CountryCode' => 'US'));
$request['RequestedShipment']['Recipient'] = array('Address' => array (
'StreetLines' => array('13450 Farmcrest Ct'), // Destination details
'City' => 'Herndon',
'StateOrProvinceCode' => 'VA',
'PostalCode' => '20171',
'CountryCode' => 'US'));
$request['RequestedShipment']['ShippingChargesPayment'] = array('PaymentType' => 'SENDER',
'Payor' => array('AccountNumber' => 'XXX', // Replace 'XXX' with payor's account number
'CountryCode' => 'US'));
$request['RequestedShipment']['RateRequestTypes'] = 'ACCOUNT';
$request['RequestedShipment']['RateRequestTypes'] = 'LIST';
$request['RequestedShipment']['PackageCount'] = '2';
$request['RequestedShipment']['PackageDetailSpecified'] = true;
$request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES'; // Or PACKAGE_SUMMARY
$request['RequestedShipment']['RequestedPackageLineItems'] = array('0' => array('Weight' => array('Value' => 2.0,
'Units' => 'LB'),
'Dimensions' => array('Length' => 10,
'Width' => 10,
'Height' => 3,
'Units' => 'IN')),
'1' => array('Weight' => array('Value' => 5.0,
'Units' => 'LB'),
'Dimensions' => array('Length' => 20,
'Width' => 20,
'Height' => 10,
'Units' => 'IN')));
try
{
$response = $client ->getRates($request);
if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR')
{
printRequestResponse($client);
}
else
{
echo 'Error in processing transaction.'. $newline. $newline;
foreach ($response -> Notifications as $notification)
{
if(is_array($response -> Notifications))
{
echo $notification -> Severity;
echo ': ';
echo $notification -> Message . $newline;
}
else
{
echo $notification . $newline;
}
}
}
writeToLog($client); // Write to log file
} catch (SoapFault $exception) {
printFault($exception, $client);
}
?>
I am not quite sure why it isn't working, i've read about using a proxy, but I am not quite sure how i would use it in this case? Isn't the point of using SOAP and WSDL to avoid using CURL, Direct Connect type stuff?
Agree with Aditya Kumar,
or check in your wsdl file at bottom. there is a code
<s1:address location="https://wsbeta.fedex.com:443/web-services/ship"/>
change it to
<s1:address location="https://ws.fedex.com:443/web-services/ship"/>
I Was also having the Same issue, i was entering the password which i was using to login, but we need to enter the password which will be sent your email address after registering for the test account information with FEDEX:
Please make sure the values you have entered below are correct:
if($var == 'shipaccount') Return 'Your Account Number';
if($var == 'meter') Return 'Your meter number';
if($var == 'key') Return 'Your key'; //These values wiil be shown in the page after registering for the test account
if($var == 'password') Return 'Your Password'; // This will be sent to you by Fedex to your mail this is not your account password using to login
If you use SoapUI ( http://www.soapui.org/ ) to contact the WSDL, what is the response you get?
(SoapUI enables you to test SOAP/Wsdl's without programming, so you can check if the calls are correct, if they are, then the problem is in your code.)
Edit fedex-common.php5 file replace 'XXX' with your info in the following params
if($var == 'shipaccount') Return 'YOUR TEST ACCOUNT NUMBER HERE';
if($var == 'billaccount') Return 'YOUR TEST ACCOUNT NUMBER HERE';
if($var == 'meter') Return 'YOUR TEST METER NUMBER HERE';
if($var == 'key') Return 'YOUR TEST KEY HERE';
if($var == 'password') Return 'YOUR TEST PASSWORD HERE';
Hope this helps someone.
in library file fedex-common.php5 change following fields to provided credentials:
if($var == 'shipaccount') Return '123456';
if($var == 'billaccount') Return '123456';
if($var == 'dutyaccount') Return '123456';
if($var == 'accounttovalidate') Return '123456';
if($var == 'meter') Return '654321';
if($var == 'key') Return 'ASDE324dfe';
if($var == 'password') Return 'K2wedrf4ASDE324dfe';
in wsdlfile ShipService_v*.wsdl change following thing:
<s1:address location="https://ws.fedex.com:443/web-services/ship"/>
Hope it'll work for you.
I faced this issue from earlier and found solution finally after a discussion with FedEx Technical Person.See why we are facing such error all because of Developer Test Account we generated from developer website.One thing we should keep in mind that Test Account Number start with "6" is of Production & Key Start with "5" is Correct Test Key.So Please check your Test Key when you get Authentication problem with Error Code 1000.
Another Reason apart from this is might be your Fedex Webservice endpoint is different like for ex "https://wsbeta.fedex.com/web-services/track", this is Sandbox mode url and in production environment url should be like this "https://ws.fedex.com/web-services/track". There is no "beta" mode in URL for Production,So please check endpoint.