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.
Related
A number of Xero accounts API samples have PHP variables which start with {
Example:
$invoices = {invoices:[{type: Invoice.TypeEnum.ACCREC, contact:{contactID:"00000000-0000-0000-000-000000000000"}, lineItems:[{ description:"Acme Tires", quantity:2.0, unitAmount:20.0, accountCode:"000", taxType:"NONE", lineAmount:40.0}], date:"2019-03-11", dueDate:"2018-12-10", reference:"Website Design", status: Invoice.StatusEnum.DRAFT}]};
I am struggling to understand how this can work. I am trying to use the API to create multiple invoices in the same call, I can do it fine in Postman so I know my code is OK.
I have tried following:
creating-an-invoice-using-oauth2-in-xero
Using the documents
But for some reason I just can't find a way to make it work.
All our SDKs and documentation is generated from our OpenAPI specs. Generating runnable code in our docs is our long term goal. In the interim, we needed to offer "some" generated docs, but the JSON payloads are not meant to be used.
We have created a sample app that demonstrates different endpoints and displays the code used to make the call.
https://github.com/XeroAPI/xero-php-oauth2-app
Here is the code you'll need to create an invoices
$result = $apiInstance->getContacts($xeroTenantId);
$contactId = $result->getContacts()[0]->getContactId();
$contact = new XeroAPI\XeroPHP\Models\Accounting\Contact;
$contact->setContactId($contactId);
$arr_invoices = [];
$invoice_1 = new XeroAPI\XeroPHP\Models\Accounting\Invoice;
$invoice_1->setReference('Ref-456')
->setDueDate(new DateTime('2019-12-10'))
->setContact($contact)
->setLineItems($lineitems)
->setStatus(XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_AUTHORISED)
->setType(XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCPAY)
->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE);
array_push($arr_invoices, $invoice_1);
$invoice_2 = new XeroAPI\XeroPHP\Models\Accounting\Invoice;
$invoice_2->setReference('Ref-123')
->setDueDate(new DateTime('2019-12-02'))
->setContact($contact)
->setLineItems($lineitems)
->setStatus(XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_AUTHORISED)
->setType(XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCPAY)
->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE);
array_push($arr_invoices, $invoice_2);
$invoices = new XeroAPI\XeroPHP\Models\Accounting\Invoices;
$invoices->setInvoices($arr_invoices);
$result = $apiInstance->createInvoices($xeroTenantId,$invoices);
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 try to implement People API, after successfully OAuth2, when try to load people, error is:
Undefined property: Google_Service_People_Resource_People::$connections
This is lines who produce error:
$people_service = new Google_Service_People($client);
$connections = $people_service->people->connections->listConnections('people/me');
Am going by this tutorial https://developers.google.com/people/v1/getting-started,
and this: https://developers.google.com/people/v1/requests.
Thanks
I think you are looking for...
$connections = $people_service->people_connections->listPeopleConnections('people/me');
We've written a PHP Google People API library that might help. It makes implementing access to Google Contacts via the Google People API much easier than using Google's own library.
Link: https://github.com/rapidwebltd/php-google-people-api
Example Usage
Usage
Retrieve all contacts
// Retrieval all contacts
foreach($people->all() as $contact) {
echo $contact->resourceName.' - ';
if ($contact->names) {
echo $contact->names[0]->displayName;
}
echo PHP_EOL;
}
Retrieve a single contact
// Retrieve single contact (by resource name)
$contact = $people->get('people/c8055020007701654287');
Create a new contact
// Create new contact
$contact = new Contact($people);
$contact->names[0] = new stdClass;
$contact->names[0]->givenName = 'Testy';
$contact->names[0]->familyName = 'McTest Test';
$contact->save();
Update a contact
// Update contact
$contact->names[0]->familyName = 'McTest';
$contact->save();
Delete a contact
// Delete contact
$contact->delete();
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