I am using the PHP Toolkit (v20) with the Enterprise WSDL to access my Salesforce objects and records in my webapp.
I successfully got everything working on my localhost.
When I uploaded the script to my webhost (inmotion), the create function simply does not work. It does not show any errors or warnings (although I have set error reporting to E_ALL), but execution of the script simply stops when it encounters the create function.
However, running a query using the query function or something like getting the server timestamp works fine.
Again, it works fine on my localhost, so I dont think its a code problem, but for the life of me I cannot figure out the problem, as no errors/warnings are displayed nor exceptions thrown.
I should clarify that although in this example I am trying to insert into my custom object, I have tried to insert into a standard Account or Contact object as well and it has not made any difference.
It will be great if somebody can guide me on how I can go about trying to troubleshoot the problem.
Thanks.
Code is as follows:
<html>
<head></head>
<body>
<?php
ini_set("soap.wsdl_cache_enabled", "0");
define("USERNAME", "myusername");
define("PASSWORD", "mypassword");
define("SECURITY_TOKEN", "mysecuritytoken");
require_once ('soapclient/SforceEnterpriseClient.php');
try {
$sflink = new SforceEnterpriseClient();
$sflink->createConnection("soapclient/auv.wsdl.xml",null,array('trace'=>true));
//$sflink->createConnection("soapclient/auv.wsdl.xml");
$sflink->login(USERNAME, PASSWORD.SECURITY_TOKEN);
// Test to get the server timestamp - Works fine.
echo "Getting Timestamp<br>";
$resp = $sflink->getServerTimestamp();
print_r($resp);
echo "<br>";
// Test to query the server - Works fine.
$query = "SELECT Id, AccountId, FirstName, LastName FROM Contact WHERE Email = 'ankur#alfauv.com'";
$response = $sflink->query($query);
echo "Select result is: <br>";
print_r($response);
echo "<br>";
// Insert into UVSI Search Object (My custom object) - Does not work
$sObject = new stdclass();
$sObject->Account__c = "00190000006yxUrAAI";
$sObject->Contact__c = "00390000005ZYLcAAO";
$sObject->Application__c = "AAP";
$sObject->Flow__c = 66;
$sObject->Flow_Unit__c = "m3-hr";
$sObject->Dose__c = 33;
$sObject->UVT__c = 99;
echo "Attempting creation<br>";
$createResponse = $sflink->create(array($sObject), 'UVSI_Search__c');
echo "This line never prints.<br/>";
} catch (Exception $e) {
echo "In error condition<br>";
echo $sflink->getLastRequest();
echo $e->faultstring;
exit();
}
?>
</body>
</html>
After breaking my head over this for 3 days, I finally found a solution. I changed the PHP version for my site from 5.2 to 5.3 and the problem just went away.
I still dont know why it did not work, but this is the solution in case anybody else has a similar problem.
Related
I have been searching around for examples but the documentation on:
http://php.net/manual/en/solrclient.query.php
and
https://www.ayalon.ch/en/code-samples/solr-php-client-example
does not give me enough information to alter for my setup.
I am trying to execute a solr query using php from my website.
The search box form method is post and the input name is q.
This is all of the php I have at the moment; I was testing the connection.
<?php
require_once('C:\Program Files\Solr\solr-7.5.0\dist\solr-php-client-master\Apache\Solr\Service.php');
$client = new Apache_Solr_Service( 'localhost', '8983', '/solr/#/sqltest' );
if ( ! $client->ping() ) {
echo 'Solr service not up dude.';
}
else{
echo 'ayee we have a connection here!';
}
//to view the specifics of this setup use
//var_dump($client);
?>
Being new to php, Im really trying to find the proper way to perform the search and display the default json response.
I already have documents indexed to search so my code does not need to add any docs as seen in some of the above tutorials.
When I use this code:
$query = new SolrQuery();
$query->setQuery('lucene');
$query->setStart(0);
$query->setRows(10);
$query->addField('id')->addField('date')->addField('Problem')->addField('Solution');
$query_response = $client->query($query);
$response = $query_response->getResponse();
print_r($response);
I get an error because the class SolrQuery is not found.
I'm trying to get product API details from the database using PHP.
<?php
class Data {
private $db;
public function __construct(){
$this->db = new soapclient('http://api.3dcart.com/cart_advanced.asmx?WSDL',array('trace'=>1,'soap_version'=>SOAP_1_1));
}
public function query($sql){
$param = array(
'storeUrl'=>"[URL]",
'userKey'=>"[KEY]",
'sqlStatement'=>$sql
);
$result = $this->db->runQuery($param);
$match = $result->runQueryResult->any;
$sxe = new SimpleXMLElement($match);
return $sxe->runQueryRecord;
}
}
$db = new Data();
$query = $db->query("SELECT * FROM product WHERE catalogid = 1");
var_dump($query);
?>
After running this program, I got this
<Error xmlns="">Error trying to get data from the store. Technical description: First request failed.This feature is disabled in demo mode. --- request params: storeURL=XXXXXXXXXXXX.3dcart.net, Method=runQuery, UserKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, UserIp=49.207.181.148, CallbackUrl=, sqlStatement=SELECT+*+FROM+product+WHERE+catalogid+%3d+1</Error>object(SimpleXMLElement)#6 (0) {
}
Really I don't know that how to get product list using PHP. If anyone knows please suggest me how to get product list.
The api you are using is in Demo mode, the error message tells you that the feature is switched off: "This feature is disabled in demo mode".
Find a way to get out of the Demo mode, probably contacting the support of 3dcart.com is a good starting point. I checked out their website and didn't find the reason why it is in demo mode.
I am trying to integrate First Data e4 Gateway using PHP. I downloaded the VinceG/php-first-data-api PHP First Data Service API class. The code comes with some examples.
I have my Terminal ID (API_LOGIN) and Password (32 character string).
What confuses me is that when I use one of the examples, I don't know how to tell the class that I want to use the demo url, not the production url.
The class comes with two constants:
const LIVE_API_URL = 'https://api.globalgatewaye4.firstdata.com/transaction/';
const TEST_API_URL = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/';
In the First Data console, when I generated my password, it said to use the v12 api, /transaction/v12, so I changed the protected $apiVersion = 'v12';
All I want to do is write my first development transaction using First Data e4. I have yet to get any kind of response. Obviously I need a lot of hand holding to get started.
When I set up a website to use BalancedPayments, they have a support forum that's pretty good, and I was able to get that running fairly quickly. First Data has a lot of documentation, but for some reason not much of it has good PHP examples.
My hope is that some expert has already mastered the VinceG/php-first-data-api, and can help me write one script that works.
Here's the pre-auth code I'm using, that invokes the FirstData class:
// Pre Auth Transaction Type
define("API_LOGIN", "B123456-01");
define("API_KEY", "xxxxxxxxxxyyyyyyyyyyyyzzzzzzzzzz");
$data = array();
$data['type'] = "00";
$data['number'] = "4111111111111111";
$data['name'] = "Cyrus Vance";
$data['exp'] = "0618";
$data['amount'] = "100.00";
$data['zip'] = "33333";
$data['cvv'] = "123";
$data['address'] = "1111 OCEAN BLVD MIAMI FL";
$orderId = "0001";
require_once("FirstData.php");
$firstData = new FirstData(API_LOGIN, API_KEY, true);
// Charge
$firstData->setTransactionType(FirstData::TRAN_PREAUTH);
$firstData->setCreditCardType($data['type'])
->setCreditCardNumber($data['number'])
->setCreditCardName($data['name'])
->setCreditCardExpiration($data['exp'])
->setAmount($data['amount'])
->setReferenceNumber($orderId);
if($data['zip']) {
$firstData->setCreditCardZipCode($data['zip']);
}
if($data['cvv']) {
$firstData->setCreditCardVerification($data['cvv']);
}
if($data['address']) {
$firstData->setCreditCardAddress($data['address']);
}
$firstData->process();
// Check
if($firstData->isError()) {
echo "!!!";
// there was an error
} else {
echo "###";
// transaction passed
}
My number one problem was that I had not created (applied for, with instant approval) a
demo account on First Data. I didn't realize this was a separate thing on First Data. On Balanced Payments, for instance, you have one account, and you can run your script on a test url with test values.
From the Administration panel, click "Terminals", then your Gateway number on the ECOMM row (will look something like AH1234-03), then you have to click "Generate" on password save it to your personal notes), then click UPDATE.
Now replace your parameter values in your test scripts. I use a variable assignment block that looks something like this:
define("API_LOGIN", "AH1234-05"); //fake
define("API_KEY", "44p7797xxx790098z1z2n6f270ys1z0x"); //fake
$data = array();
$data['type'] = "03";
$data['number'] = "4111111111111111";
$data['name'] = "Cyrus Vancce";
$data['exp'] = "0618";
$data['amount'] = "100.00";
$data['zip'] = "33320";
$data['cvv'] = "123";
$data['address'] = "1234 N OCEAN BLVD MIAMI BEACH FL";
$orderId = "0001";
require_once("FirstData.php");
$firstData = new FirstData(API_LOGIN, API_KEY, true);
at the end of the VinceG test scripts, I output my gateway response with a print_r, like this:
$firstData->process();
// Check
if($firstData->isError()) {
echo "!!!";
// there was an error
} else {
echo "###";
// transaction passed
}
echo "<pre>";
print_r($firstData);
I recently swithced php version from 4 to 5.3. I now how some code that is not working anymore. I have a PHP script that fetches data from a form into a new form, when a user clicks a link.
First it recognizes the user/account and after that it finds the form data.
This is the code for the account data:
$account_info = ft_get_account_info($_SESSION["ft"]["account"]["account_id"]);
$emailadresse = ($account_info['email']);
$accountid = ($account_info['account_id']);
$firstname =($account_info['first_name']);
$lastname =($account_info['last_name']);
....
....
This works, and i can display the data through for example a:
<?php echo $_POST['firstname']; ?>
I then have this code in order to fetch and display the form data:
$submission_info = ft_get_submission_info($form_id, $submission_id);
$submission_id = ($submission_info['submission_id']);
$partname = ($submission_info['partname']);
$ponumber = ($submission_info['ponumber']);
....
....
<?php echo $_POST['partname']; ?>
This is not working anymore in version 5.3 of PHP.
Can anyone please tell what i need to re-write this code into, in order for it to work...????
Thanks in advance!
In addition to the comments i have this code for the ft_get_account_info:
$_SESSION["ft"]["account"] = ft_get_account_info($account_info["account_id"]);
And this for the ft_get_submission_info:
/**
* Returns all information about a submission. N.B. Would have been nice to have made this just a
* wrapper for ft_get_submission_info, but that function contains hooks. Need to revise all core
* code to allow external calls to optionally avoid any hook calls.
*
* #param integer $form_id
* #param integer $submission_id
*/
function ft_api_get_submission($form_id, $submission_id)
{
global $g_table_prefix, $g_api_debug;
// confirm the form is valid
if (!ft_check_form_exists($form_id))
{
if ($g_api_debug)
{
$page_vars = array("message_type" => "error", "error_code" => 405, "error_type" => "user");
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}
else
return array(false, 405);
}
if (!is_numeric($submission_id))
{
if ($g_api_debug)
{
$page_vars = array("message_type" => "error", "error_code" => 406, "error_type" => "user");
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}
else
return array(false, 406);
}
// get the form submission info
$submission_info = mysql_query("
SELECT *
FROM {$g_table_prefix}form_{$form_id}
WHERE submission_id = $submission_id
");
$submission = mysql_fetch_assoc($submission_info);
return $submission;
}
Nothing on the error reporting.
I don't know what your specific issue is, but I figure that if you use all the tools available to you for debugging, you'll be able to find your issue easily.
For development, you should always up your error reporting level to E_ALL ^ E_STRICT. You can find this setting in your php.ini file. E_STRICT specifically will help identify interoperability and compatibility issues, and is not included in E_ALL until PHP 5.4, according to the manual.
You may also want to use Netbeans and XDebug, which should allow you to step through your code line by line, which will simplify debugging immensely. There is a guide for setting up these tools here: Debugging PHP Source Code in the NetBeans IDE
I am trying to write an application that integrates with the Affiliate Window API. The only problem I have is I have literally 0 experience in php and so find myself unable to debug even the most elementary of issues.
I downloaded the below code which is supposed to be a sample application. Unfortunately running it fails at the first hurdle:
Invalid argument supplied for foreach() in /Users/ravinthambapillai/Downloads/api.client/listmerchants.php on line 9
This is the error message I get when I run the below:
Can anyone help me with what I need to fix to get this right?
<?php
define('API', 'PS');
require_once('constants.inc.php');
require_once('classes/class.ClientFactory.php');
$oClient = ClientFactory::getClient(REDACTED, REDACTED, merchant);
$listmerchants = array('iCategoryId'=> 97, 'iMaxResult' => 10);
echo 'hello world';
$oResponse= $oClient->call('getMerchantList', $listmerchants);
foreach($oResponse->oMerchant as $details){
$name = $details->sName;
$strapline = $details->sStrapline;
$description = $details->sDescription;
$logo = $details->sLogoUrl;
$showurl = $details->sDisplayUrl;
$deeplink = $details->sClickThroughUrl;
$id = $details->iId;
if ($logo<>'') {
echo "<a href=".$deeplink." title='".$name."'><img src=".$logo.
" style='float:left; margin:5px;' alt='".$name.
" :: ".$strapline." :: ".$description." :: ".$showurl.
"' width=\"88\" height=\"31\" border=\"0\"></a>";
}
}
?>
Did you update the constants in constants.inc.php?
API_USERNAME needs to be set to your account ID, and API_PASSWORD needs to be set to your Affiliate API Password as seen at https://www.affiliatewindow.com/affiliates/accountdetails.php (when you're logged in)