Let me set the scene:
I'm a PHP developer that needs to take info from a web form and send it into a clients Salesforce. At first I though it was as simple as using Web2Lead. However the client has a Salesforce developer in house.
The in house developer has sent me partner.wsdl and CatalystWebservice.wsdl files along with login details to their sandbox to run all this on. The in house developer has basically said I need to use the SOAP API of Salesforce and once connected and logged in I need to call ->makeContact("FormField1", "FormField2", "etc...");
So after spending all day trying many things and hitting many problems I have finally hit a wall I cannot climb. Here is my PHP code I have now:
<pre>
<?php
define("SOAP_CLIENT_BASEDIR", "../soapclient");
$USERNAME = '******#********' ;
$PASSWORD = '******************************' ;
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
try {
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner2.wsdl.xml');
$loginResult = $mySforceConnection->login($USERNAME, $PASSWORD);
$location = $mySforceConnection->getLocation();
$session_ID = $mySforceConnection->getSessionId();
$client = new SoapClient(SOAP_CLIENT_BASEDIR.'/CatalystWebservice.wsdl.xml');
$sforce_header = new SoapHeader("http://soap.sforce.com/schemas/class/CatalystWebservice", "SessionHeader", array( "sessionId" => $session_ID ) );
$client->__setSoapHeaders( array( $sforce_header ) );
$client->makeContact("*****", "*****", "Address1", "Address2", "London", "****", "no-one#****", "0123456789", "07891236456", "New Build Homebuy", "This is my question\n\nAnd an other line", "1", "Test");
} catch (Exception $e) {
print_r($e);
}
?>
</pre>
I have starred out sensitive information for here. When I run the above code I get the following output:
SoapFault Object
(
[message:protected] => UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: ***********-*** (***********)
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /home/******/public_html/********/test/partner.php
[line:protected] => 23
[trace:Exception:private] => Array
(
[0] => Array
.....
And the CatalystWebservice.wsdl.xml file
The in house developer has developed something in C# to test his WebService and it works perfectly fine so it must be something I am not doing right. What am I doing incorrectly?
I found the solution... I had to make sure I was sending the data as an associative array like so:
$response = $client->makeContact
(
array
(
"sLastName" => (string) $wpcf7_data->posted_data['last-name'],
"sFirstName" => (string) $wpcf7_data->posted_data['first-name'],
"sAddress1" => (string) $wpcf7_data->posted_data['address-one'],
"sAddress2" => (string) $wpcf7_data->posted_data['address-two'],
"sCity" => (string) $wpcf7_data->posted_data['town-city'],
"sPostcode" => (string) $wpcf7_data->posted_data['post-code'],
"sEmail" => (string) $wpcf7_data->posted_data['email-address'],
"sPhone" => (string) $wpcf7_data->posted_data['telephone'],
"sMobile" => (string) "",
"sEnquiries" => (string) $wpcf7_data->posted_data['enquiry'],
"sComment" => (string) $wpcf7_data->posted_data['comments'],
"sPropertyID" => (string) wpcf7_special_mail_tag_for_post_data( "", "_post_id" ),
"sPropertyName" => (string) wpcf7_special_mail_tag_for_post_data( "", "_post_title" ),
)
);
Related
I am trying to use the updateListing method to revise listing descriptions...
https://www.etsy.com/developers/documentation/reference/listing#method_updatelisting
I went through the OAuth Authentication process successfully and am able to make an authorized request via the API as per the example in the documentation. I am having problems with the updateListing method. I am trying to revise the description but get the following error…
“Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)Expected param 'quantity'.Array”
As per the documentation, the quantity is not required (and is actually depreciated for updateListing). When I use the existing quantity to populate ‘quantity’ in the array (commented out), it complains about another field it expects. I’m not sure why I’m getting an error regarding these fields as they are not required. I would not mind using the existing attributes available from my listing to populate these fields but there is a “shipping_template_id” field which I don’t currently have available. I can’t set it to null because it expects a numeric value. When I set it to 0, it says that it’s not a valid shipping template ID. I must be doing something wrong.
Here is my code (I replaced my actual token and token secrets)…
$access_token = "my token";
$access_token_secret = "my secret";
$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
$oauth->setToken($access_token, $access_token_secret);
try {
$url = "https://openapi.etsy.com/v2/private/listings";
$params = array('listing_id' => $result->listing_id,
//'quantity' => $result->quantity,
//'title' => $result->title,
'description' => $new_description);
$oauth->fetch($url, $params, OAUTH_HTTP_METHOD_POST);
$json = $oauth->getLastResponse();
print_r(json_decode($json, true));
}
catch (OAuthException $e) {
echo $e->getMessage();
echo $oauth->getLastResponse();
echo $oauth->getLastResponseInfo();
}
$args = array(
'data' => array(
"quantity" => $quantity,
"title" => $title,
"description" => strip_tags($description),
"price" => $price,
"materials" => $materials,
"shipping_template_id" =>(int)$shippingTemplateId,
"non_taxable" => false,
"state" => "$ced_etsy_upload_product_type",
"processing_min" => 1,
"processing_max" => 3,
"taxonomy_id" => (int)$categoryId,
"who_made" => $who_made,
"is_supply" => true,
"when_made" => $when_made,
)
);
Please try this may be this will help you.
Iam new to paypal php SDK this is the code iam using
$RPProfileDetails = new RecurringPaymentsProfileDetailsType();
$RPProfileDetails->SubscriberName = 'Test Customer';
$RPProfileDetails->BillingStartDate = '29/5/2016';
$activationDetails = new ActivationDetailsType();
$activationDetails->InitialAmount = new BasicAmountType($currencyCode, 10);
$activationDetails->FailedInitialAmountAction = 'ContinueOnFailure';//$_REQUEST['failedInitialAmountAction'];
$paymentBillingPeriod = new BillingPeriodDetailsType();
$paymentBillingPeriod->BillingFrequency = 365;//$_REQUEST['billingFrequency'];
$paymentBillingPeriod->BillingPeriod = 'Day';//$_REQUEST['billingPeriod'];
$paymentBillingPeriod->TotalBillingCycles = 365;//$_REQUEST['totalBillingCycles'];
$paymentBillingPeriod->Amount = new BasicAmountType($currencyCode, 10);//$_REQUEST['paymentAmount']
$scheduleDetails = new ScheduleDetailsType();
$scheduleDetails->Description = 'Artist Access amount';//$_REQUEST['profileDescription'];
$scheduleDetails->PaymentPeriod = $paymentBillingPeriod;
$createRPProfileRequestDetail = new CreateRecurringPaymentsProfileRequestDetailsType();
$_REQUEST['token'] ='';
if(trim($_REQUEST['token']) != "") {
$createRPProfileRequestDetail->Token = $_REQUEST['token'];
} else {
$creditCard = new CreditCardDetailsType();
$creditCard->CreditCardNumber = '41111111111111111';//$_REQUEST['creditCardNumber'];
$creditCard->CreditCardType = 'Visa';//$_REQUEST['creditCardType'];
$creditCard->CVV2 = '111';//$_REQUEST['cvv'];
$creditCard->ExpMonth = '9';//$_REQUEST['expMonth'];
$creditCard->ExpYear = '2022';//$_REQUEST['expYear'];
$createRPProfileRequestDetail->CreditCard = $creditCard;
}
$createRPProfileRequestDetail->ScheduleDetails = $scheduleDetails;
$createRPProfileRequestDetail->RecurringPaymentsProfileDetails = $RPProfileDetails;
$createRPProfileRequest = new CreateRecurringPaymentsProfileRequestType();
$createRPProfileRequest->CreateRecurringPaymentsProfileRequestDetails = $createRPProfileRequestDetail;
$createRPProfileReq = new CreateRecurringPaymentsProfileReq();
$createRPProfileReq->CreateRecurringPaymentsProfileRequest = $createRPProfileRequest;
$config = array(
// values: 'sandbox' for testing
// 'live' for production
"mode" => "sandbox",
'log.LogEnabled' => true,
'log.FileName' => '../PayPal.log',
'log.LogLevel' => 'FINE',
// These values are defaulted in SDK. If you want to override default values, uncomment it and add your value.
// "http.ConnectionTimeOut" => "5000",
// "http.Retry" => "2",
// Signature Credential
"acct1.UserName" => "asp.mobileappz_api1.gmail.com",
"acct1.Password" => "TR2R87Q3W7XT7UJQ",
"acct1.Signature" => "AFcWxV21C7fd0v3bYYYRCpSSRl31Abq4txmPS2AOjtNVgh-ZRkhGwY3D",
// Subject is optional and is required only in case of third party authorization
// "acct1.Subject" => "",
// Sample Certificate Credential
// "acct1.UserName" => "certuser_biz_api1.paypal.com",
// "acct1.Password" => "D6JNKKULHN3G5B8A",
// Certificate path relative to config folder or absolute path in file system
// "acct1.CertPath" => "cert_key.pem",
// Subject is optional and is required only in case of third party authorization
// "acct1.Subject" => "",
);
$paypalService = new PayPalAPIInterfaceServiceService($config);
try {
/* wrap API method calls on the service object with a try catch */
$createRPProfileResponse = $paypalService->CreateRecurringPaymentsProfile($createRPProfileReq);
} catch (Exception $ex) {
echo '<pre>';
PRINT_r($ex);
//include_once("../Error.php");
exit;
}
if(isset($createRPProfileResponse)) {
echo "<table>";
echo "<tr><td>Ack :</td><td><div id='Ack'>$createRPProfileResponse->Ack</div> </td></tr>";
echo "<tr><td>ProfileID :</td><td><div id='ProfileID'>".$createRPProfileResponse->CreateRecurringPaymentsProfileResponseDetails->ProfileID ."</div> </td></tr>";
echo "</table>";
echo "<pre>";
print_r($createRPProfileResponse);
echo "</pre>";
}
}
Ack :
Failure
ProfileID :
PayPal\PayPalAPI\CreateRecurringPaymentsProfileResponseType Object
(
[CreateRecurringPaymentsProfileResponseDetails] => PayPal\EBLBaseComponents\CreateRecurringPaymentsProfileResponseDetailsType Object
(
[ProfileID] =>
[ProfileStatus] =>
[TransactionID] =>
[DCCProcessorResponse] =>
[DCCReturnCode] =>
)
[Timestamp] => 2016-06-07T03:29:31Z
[Ack] => Failure
[CorrelationID] => 9c2a8533bb7f5
[Errors] => Array
(
[0] => PayPal\EBLBaseComponents\ErrorType Object
(
[ShortMessage] => Security error
[LongMessage] => Security header is not valid
[ErrorCode] => 10002
[SeverityCode] => Error
[ErrorParameters] =>
)
)
[Version] => 106.0
[Build] => 22204133
)
I have crossed check its not because of wrong credentails i have setup an sandbox account on developer.paypal.com the url is that sdk create is also of sand box, but show how its not working please help. i have absolutely no clue. also this is an standard example from paypal sdk itself. please suggest where iam wrong.
10002 refers to incorrect API credentials,
you are using live PayPal account credentials and the code is set for sandbox
"mode" => "sandbox",
Change this to Live environment and try again.
My problem is quite strange (at least to me) as I have a request URL that works in the console but throws the Sorry, that page does not exist error in my php script, even though the connection is up and running.
So this
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_secret']);
$user = $connection->get('account/verify_credentials');
print_r($user);
works great, the $user data is printed out on the screen.
However, I am unable to check a friendship status as:
$x = $connection->get('https://api.twitter.com/1.1/friendships/show.json?source_id=707482092&target_id=755811768&target_screen_name=assetspersonifi');
As I get the error.
When I put this request into the Twitter API console, it gives back the json that I don't receive in my php code.
I'm using Abraham's twitteroauth library but this does not work either:
$follows_faelazo = $connection->get('friendships/exists', array('user_a' => 'blfarago', 'user_b' => 'faelazo'));
if(!$follows_faelazo){
echo 'You are NOT following #faelazo!';
$connection->post('friendships/create', array('screen_name' => 'faelazo'));
} else {
print_r($follows_faelazo);
}
stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Sorry, that page does not exist [code] => 34 ) ) )
I read that friendships/exists API is no longer supported by the Twitter API and I should use friendships/show but how if it's not working as you see above?
To prove that everything else is working, I can follow others with
$connection->post('friendships/create', array('screen_name' => 'faelazo'));
Why?
I found a way. Here's the documentation
$following = $connection->get('friendships/show', array(
'source_screen_name' => $_SESSION['username'],
'target_screen_name' => $screen_name_to_follow,
));
An alternative would be
$following = $connection->get('friendships/lookup', array('screen_name' => $screen_name_to_follow));
Look it up in Twitter doc.
I am doing a PHP SOAP Request as follows (my code, location removed as I'm not allow to publish)
try {
$location = "http://myUrltoWSDLhere";
$client = new SoapClient($location,
array(
'soap_version' => SOAP_1_1,
'login' => 'myuser',
'password' => 'mypass'
));
$params = array(array('BUKRS'=> 1));
$x = $client->ZIbFtiWsCredPosToWeb( $params );
print_r($x);
} catch (Exception $e) {
echo $e->getMessage();
}
I've been trying countless combinations how to pass the params to my method and I am doing a print_r($x) and gives me the below output.
stdClass Object ( [EBkpf] => stdClass Object ( ) [EMsgnr] => 6 [EMsgtxt] => BUKRS is missing [EMsgtyp] => E [ESstMon] => 00000000000000000000 )
Important: SoapClient getTypes returns the following for this method and the IBukrs is the field I am trying to pass data to. In SAP the Company Code is "BUKRS" so I had tried BUKRS and IBukrs and also Bukrs.
Any help would be greatly appreciated!!
[43] => struct ZIbFtiWsCredPosToWeb {
int IAnz;
char1 IAp;
char4 IBukrs;
ZibSstGjahr IGjahr;
ZibSstCredTt IKreditor;
char1 IOp;
numeric20 ISstMon;
}
WSDL Content: http://pastebin.com/fU5PhD9B
I'm trying to post a photo using the php-sdk - all was working for months successfully but all of the sudden no dice.
Other functions are still working with the same code base (ie: posting messages to wall) - its just the posting of photos that broke on my side.
try {
$data = $facebook->api('/me/photos', 'post', $args);
} catch (FacebookApiException $e) {
print_r($e);}
Is dumping:
FacebookApiException Object ( [result:protected] => Array ( [error_code] => 3 [error] => Array ( [message] => No URL set! [type] => CurlException ) ) [message:protected] => No URL set! [string:private] => [code:protected] => 3 [file:protected] => /locationofmy/base_facebook.php [line:protected] => 818 [trace:private] => Array ( [0] => Array [..............]
From the FB php-sdk lines 818:
if ($result === false) {
$e = new FacebookApiException(array(
'error_code' => curl_errno($ch),
'error' => array(
'message' => curl_error($ch),
'type' => 'CurlException',
),
));
curl_close($ch);
throw $e;
}
curl_close($ch);
return $result;
}
This was working for a long time - has something changed on Facebooks side?
EDIT: php-sdk version: 3.1.1
EDIT 2:
$tag = array(
'tag_uid' => 'acct_num',
'x' => 0,
'y' => 0
);
$tags[] = $tag;
$args = array(
'message' => $item_description,
'image' => '#' . realpath($temp_path . $tempFile),
'tags' => $tags,
);
Probably that the file doesnt exist, or the file system can't serve it anymore. Can you confirm "$temp_path . $tempFile" - the error is no URL, usually that means no real path to image. I suspect, that the images are missing and/or your servers filled up and no local images are saving. (Yes, this has happened to me before!)
Try changing the image to source. I believe this should fix your issue.
The Facebook API requires a source field but I did not see anything about an image field.
You may also have to pass the actual file contents instead of the real_path (based on the example). Or, alternatively, pass an external URL (based on my understanding of the documentation).
Source: https://developers.facebook.com/docs/reference/api/photo/
Example: https://developers.facebook.com/blog/post/498/