Unable to get getConfigurationAndPricing in PromoStandard - soap

I am trying to getting Product getConfigurationAndPricing using Promostandard Soap API but for some reason I am unable to get those information. Here is my code snapit
$productId = 'TM17907'
$client = new \SoapClient("https://pspriceconfig100.pcna.online/psPriceConfig.svc?singleWsdl", array('trace' => 1));
$options = array(
'wsVersion' => '1.0.0',
'id' => $apiUsername,
'password' => $apiPassword,
'productId' => $productId,
'currency' => 'USD',
'fobId' => '1',
'priceType' => 'List',
'localizationCountry'=>'US',
'localizationLanguage' => 'en',
'configurationType' => 'Decorated',
'cache_wsdl' => WSDL_CACHE_MEMORY
);
try{
$result = $client->__soapCall('getConfigurationAndPricing',[$options]);
} catch (\Exception $e){
$output->writeln("<error>HTTP issue generate in product ID : ".$productId.", Row No.".$currentRow."</error>");
continue;
}
I am using to get PCNA products.

Related

Argument 1 passed to GuzzleHttp\Client::send() must implement interface

hi I am new to laravel and I am trying to consume the api with laravel 8 I have a problem with my POST and I do not understand
public function storeEntreprise(Request $request){
$request->validate([
'name' => 'required',
'email' => 'required',
'phone_number'=>'required',
'address' => 'required',
'password' => 'required',
'password_confirmation' => 'required'
]);
$client = new Client();
$post = $request->all();
$url = "http://flexy-job.adsyst-solutions.com/api/entreprises-store";
$create = $client->request('POST', $url, [
'headers' => [
'Content-Type' => 'text/html; charset=UTF8',
],
'form-data' => [
'name' => $post['name'],
'email' => $post['email'],
'phone_number' => $post['phone_number'],
'address' => $post['address'],
'logo' => $post['logo'],
'password' => $post['password'],
'password_confirmation' => $post['password_confirmation']
]
]);
//dd($create->getBody());
echo $create->getStatusCode();
//echo $create->getHeader('Content-Type');
echo $create->getBody();
$response = $client->send($create);
return redirect()->back();
}
Can you help me please
You calling (accidentally?) $response = $client->send($create); where $create is response of API request you made ($create = $client->request('POST', $url, ...).
So PHP reports you that you can't pass ResponseInterface where RequestInterface required.
Also, you echo's body of response, and return redirect response at same time. So browser will not show you API response (because of instance back redirect).

Fedex SOAP Request Failing

I am looking for the reason why the below request is failing to retrieve information. This is copied from the Fedex developer website and it doesn't work. When my program hits the GetRates line it throws a could not connect to host exception. I tried adding the connection_timeout and setting the default_timeout in php and neither appear to work. I contacted the Fedex dev team and they are receiving my post successfully I am just not able to get any response besides the fault. Has anyone had experience with Fedex or know what might cause this to be failing?
I am posting my current code below. I am using PHP7 on an AS400 machine using Zendserver.
<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0
require_once('../library/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 = "../wsdl/RateService_v24.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
ini_set('soap.wsdl_cache_ttl',0);
$client = new SoapClient($path_to_wsdl, array('trace' => 1, 'connection_timeout' => 30)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'crs',
'Major' => '24',
'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'] = 'INTERNATIONAL_PRIORITY'; // 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']['TotalInsuredValue']=array(
'Ammount'=>100,
'Currency'=>'USD'
);
$request['RequestedShipment']['Shipper'] = addShipper();
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
try {
if(setEndpoint('changeEndpoint')){
$newLocation = $client->__setLocation(setEndpoint('endpoint'));
}
$response = $client -> getRates($request);
if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR'){
$rateReply = $response -> RateReplyDetails;
echo '<table border="1">';
echo '<tr><td>Service Type</td><td>Amount</td><td>Delivery Date</td></tr><tr>';
$serviceType = '<td>'.$rateReply -> ServiceType . '</td>';
if($rateReply->RatedShipmentDetails && is_array($rateReply->RatedShipmentDetails)){
$amount = '<td>$' . number_format($rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount,2,".",",") . '</td>';
}elseif($rateReply->RatedShipmentDetails && ! is_array($rateReply->RatedShipmentDetails)){
$amount = '<td>$' . number_format($rateReply->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Amount,2,".",",") . '</td>';
}
if(array_key_exists('DeliveryTimestamp',$rateReply)){
$deliveryDate= '<td>' . $rateReply->DeliveryTimestamp . '</td>';
}else if(array_key_exists('TransitTime',$rateReply)){
$deliveryDate= '<td>' . $rateReply->TransitTime . '</td>';
}else {
$deliveryDate='<td> </td>';
}
echo $serviceType . $amount. $deliveryDate;
echo '</tr>';
echo '</table>';
printSuccess($client, $response);
}else{
printError($client, $response);
}
writeToLog($client); // Write to log file
} catch (SoapFault $exception) {
printFault($exception, $client);
}
function addShipper(){
$shipper = array(
'Contact' => array(
'PersonName' => 'Sender Name',
'CompanyName' => 'Sender Company Name',
'PhoneNumber' => '9012638716'
),
'Address' => array(
'StreetLines' => array('Address Line 1'),
'City' => 'Collierville',
'StateOrProvinceCode' => 'TN',
'PostalCode' => '38017',
'CountryCode' => 'US'
)
);
return $shipper;
}
function addRecipient(){
$recipient = array(
'Contact' => array(
'PersonName' => 'Recipient Name',
'CompanyName' => 'Company Name',
'PhoneNumber' => '9012637906'
),
'Address' => array(
'StreetLines' => array('Address Line 1'),
'City' => 'Richmond',
'StateOrProvinceCode' => 'BC',
'PostalCode' => 'V7C4V4',
'CountryCode' => 'CA',
'Residential' => false
)
);
return $recipient;
}
function addShippingChargesPayment(){
$shippingChargesPayment = array(
'PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
'Payor' => array(
'ResponsibleParty' => array(
'AccountNumber' => getProperty('billaccount'),
'CountryCode' => 'US'
)
)
);
return $shippingChargesPayment;
}
function addLabelSpecification(){
$labelSpecification = array(
'LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY
'ImageType' => 'PDF', // valid values DPL, EPL2, PDF, ZPLII and PNG
'LabelStockType' => 'PAPER_7X4.75'
);
return $labelSpecification;
}
function addSpecialServices(){
$specialServices = array(
'SpecialServiceTypes' => array('COD'),
'CodDetail' => array(
'CodCollectionAmount' => array(
'Currency' => 'USD',
'Amount' => 150
),
'CollectionType' => 'ANY' // ANY, GUARANTEED_FUNDS
)
);
return $specialServices;
}
function addPackageLineItem1(){
$packageLineItem = array(
'SequenceNumber'=>1,
'GroupPackageCount'=>1,
'Weight' => array(
'Value' => 50.0,
'Units' => 'LB'
),
'Dimensions' => array(
'Length' => 108,
'Width' => 5,
'Height' => 5,
'Units' => 'IN'
)
);
return $packageLineItem;
}
?>

Facebook login showing not defined index: email only for gmail users

I've made App and facebook login for my site. But I've tested it and it works for another type of mail. I tried now with gmail and it's showing:
ErrorException [ Notice ]: Undefined index: email
My method for that is:
public function action_fbLogin(){
$facebook = new Facebook(array(
'appId' => 'MyAppId',
'secret' => 'MySecret',
));
$user = $facebook->getUser();
if ($user) {
$user_profile = $facebook->api('/me', array('fields' => 'id,email,name,first_name,last_name,picture'));
$user_id = Model_UserFunctions::checkIfUserExist($user_profile['email']);
if($user_id > 0)
{
Session::instance()->set('user', array(
'fb_id' => $user_profile['id'],
'user_id' => $user_id,
'pic' => $user_profile['picture'],
'email' => $user_profile['email'],
'first_name' => $user_profile['first_name'],
'last_name' => $user_profile['last_name'],
));
$this->redirect('profile');
exit;
}
$values = array(
'email' => $user_profile['email'],
'username' => $user_profile['email'],
'password' => '12345678'
);
$user = ORM::factory ( 'User' );
$user->values($values);
try
{
if($user->save()){
$user_new_id = $user->as_array();
$user_new_id = $user_new_id['id'];
Session::instance()->set('user', array(
'fb_id' => $user_profile['id'],
'user_id' => $user_new_id,
'pic' => $user_profile['picture'],
'email' => $user_profile['email'],
'first_name' => $user_profile['first_name'],
'last_name' => $user_profile['last_name'],
));
$this->redirect('profile');
}
}
catch (ORM_Validation_Exception $e)
{
$result = $e->errors('models');
echo '<pre>';
print_r($result);
exit;
}
}
else
{
$this->redirect($facebook->getLoginUrl(array('id,email,name,first_name,last_name,picture')));
}
exit;
}
Are there other things that I should add to my code for gmail users? Thank you in advance!
Edited: my method for logut is:
public function action_logout(){
Session::instance()->delete('user');
$this->redirect('/');
}
Maybe problem is that it doesn't logout. I'm not sure. It shows me the same user data although I'm logged with different user.

how to use auto_increment in fuelphp to create table

I write a fileds like this
$fileds = array(
'id' => array('type' => 'integer','AUTO_INCREMENT'=>true),
'user' => array('type' => 'text'),
'time' => array('type' => 'integer')
);
When I run thisDBUtil::create_table($table, $fileds);
it turn wrong,
exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error' in /home/yangjun/phpenv/public_html/cmanage/fuel/core/classes/database/pdo/connection.php:239
What is wrong ?
ihave rewrite a new test,and add primary key,but doesn't work,i read the document in fuelphp,no idea~
<?php
/**
* #group test
*/
class Test extends TestCase
{
public static function setUPBeforeClass()
{
DBUtil::set_connection('request');
$table = 'test';
$fileds = array(
'_id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true),
'_name' => array('type' => 'test'),
'_data' => array('type' => 'test')
);
$primary_keys = array('_id');
DBUtil::create_table($table, $fileds, $primary_keys);
}
public function test_add_keycode_request()
{
$RequestData = array(
'_id' => '',
'_name' => 'hhh',
'_data' => 'ggg');
$RequestData1 = array(
'_id' => '',
'_name' => 'hhhh',
'_data' => 'gggg');
self::add_request($RequestData);
self::add_request($RequestData1);
Cli::write(__METHOD__ . " √ \n", 'green');
}
public static function add_request($RequestData)
{
try {
$result = \DB::insert('test')
->set($RequestData)
->execute('request');
} catch (\Database_Exception $e) {
\Log::error('DB access Error' . $e);
throw $e;
}
return $result;
}
}
error log,this is whole error log,synatax error?
Test
1.exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error' in /home//phpenv/public_html/fuel/core/classes/database/pdo/connection.php:239
2.Next exception 'Fuel\Core\Database_Exception' with message 'SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error with query: "CREATE TABLE IF NOT EXISTS "test" (
"_id" int(11) NOT NULL AUTO_INCREMENT,
"_name" test NOT NULL,
"_data" test NOT NULL,
PRIMARY KEY "_id" ("_id"));"' in /home/yangjun/phpenv/public_html/fuel/core/classes/database/pdo/connection.php:272
Seems is missing the constraint param on columns field (i don't know also if int or integer type field).
Try this:
$fileds = array(
'id' => array('constraint' => 11,'type' => 'integer','AUTO_INCREMENT'=>true),
'user' => array('type' => 'text'),
'time' => array('constraint' => 11, 'type' => 'integer'))
}
UPDATE
Need to specify the primary key also:
DBUtil::create_table($table, $fileds, array('id'));
More info in the doc here
Hope this help

FuelPHP Sentry Insert Group on Regstration

I can't really find anything about this in the documentation.
I used Codeigniter a lot, and I used Ben Edmunds Ion auth mostly, and that was a bit easier for me, because there I was able to add a group insert function in the registration.
You can down vote this stupid question, but I can't find anything about this in the Sentry docs.
Here is my register code:
public function action_register()
{
$response = Response::forge();
// validation
$val = Validation::forge('registration');
$val->add_field('first_name', 'Username', 'required|trim|valid_string[alpha,spaces]');
//$val->add_field('first_name', 'Vezetéknév', 'required|');
$val->add_field('last_name', 'Keresztév', 'required');
$val->add_field('email', 'Email', 'required|valid_email');
$val->add_field('email_again', 'Email újra', 'required|valid_email|match_field[email]');
$val->add_field('password', 'Jelszó', 'required|min_length[5]');
$val->add_field('gender', 'Nemed', 'required');
$val->add_field('talent', 'Tehetséged', 'required');
$val->add_field('talent_level', 'Tehetségi szinted', 'required');
if($val->run()):
try
{
// register the user
$user = Sentry::user()->register(array(
'email' => Input::post('email'),
'password' => Input::post('password'),
'metadata' => array(
'first_name' => Input::post('first_name'),
'last_name' => Input::post('last_name'),
'gender' => Input::post('gender'),
'talent_level' => Input::post('talent_level'),
)
));
if($user):
//$email_data = array();
//echo Config::get('base_url'). "user/activate/". $user['hash'];
$email = Email::forge();
$email->from('my#email.me', Config::get('site_name'));
$email->to(Input::post('email'), Input::post('first_name'));
$email->subject('Regisztráció');
$email_data = array(
'name' => "Kedves " . Input::post('first_name'). "<br><br>",
'title' => "Üdvözöllek a ".Config::get('site_name')." oldalán" ."<br>",
'link' => 'Fiókod megerősítéséhez kérlek kattints ide'
);
$email->html_body(\View::forge('email/activation', array('email_data' => $email_data)));
$email->send();
$response->body(json_encode(array(
'status' => 'ok',
)));
else:
$data['errors'] = "error";
endif;
}
catch (SentryUserException $e)
{
$response->body(json_encode(array(
'status' => 'error',
'message' => array(
'email_taken' => $e->getMessage()
)
)));
}
else:
$response->body(json_encode(array(
'status' => 'error',
'message' => array(
'first_name' => $val->error('first_name') ? $val->error('first_name')->get_message() : null,
'last_name' => $val->error('last_name') ? $val->error('last_name')->get_message() : null,
'email' => $val->error('email') ? $val->error('email')->get_message() : null,
'email_again' => $val->error('email_again') ? $val->error('email_again')->get_message() : null,
'password' => $val->error('password') ? $val->error('password')->get_message() : null,
'gender' => $val->error('gender') ? $val->error('gender')->get_message() : null,
'talent' => $val->error('talent') ? $val->error('talent')->get_message() : null,
'talent_level' => $val->error('talent_level') ? $val->error('talent_level')->get_message() : null,
)
)));
endif;
return $response;
}
So my question is how can I make it save the user group selected?
Thank you.
This is taken from the Sentry Documentation; I think this is what you are after:
try
{
// option 1
$user->add_to_group(2);
// option 2
$user->add_to_group('editor');
}
catch (SentryUserException $e)
{
$errors = $e->getMessage(); // catch errors such as user already in group
}