I've been trying to sync QB-Web Connector but I keep receiving errors:
The first was: 'Fatal error: Class 'QuickBooks_Loader' not found', which I fixed by adding including the file location at the top of the page: include_once("$_SERVER[DOCUMENT_ROOT]/qb/QuickBooks/Loader.php");
Now I am getting the following error from the web-connector:
QBWC1012: Authentication failed due to following error message. Client
found response content type of 'text/html', but expected 'text/xml'.
The request failed with an empty response. See QWCLog for more
details. Remember to turn logging on.
I checked all the files to be sure that the content type is text/xml, still no dice. Please help.
<?php
/**
* Example of generating QuickBooks *.QWC files
*
* #author Keith Palmer <keith#consolibyte.com>
*
* #package QuickBooks
* #subpackage Documentation
*/
// Error reporting...
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
/**
* Require the utilities class
*/
require_once '../QuickBooks.php';
$name = 'My QuickBooks SOAP Server'; // A name for your server (make it whatever you want)
$descrip = 'An example QuickBooks SOAP Server'; // A description of your server
$appurl = 'https://www.domain.com/qb/QuickBooks/SOAP/Server.php'; // This *must* be httpS:// (path to your QuickBooks SOAP server)
$appsupport = 'https://www.domain.com'; // This *must* be httpS:// and the domain name must match the domain name above
$username = ''; // This is the username you stored in the 'quickbooks_user' table by using QuickBooks_Utilities::createUser()
$fileid = '57F3B9B6-86F1-4FCC-B1FF-966DE1813D20'; // Just make this up, but make sure it keeps that format
$ownerid = '57F3B9B6-86F1-4FCC-B1FF-166DE1813D20'; // Just make this up, but make sure it keeps that format
$qbtype = QUICKBOOKS_TYPE_QBFS; // You can leave this as-is unless you're using QuickBooks POS
$readonly = false; // No, we want to write data to QuickBooks
$run_every_n_seconds = 600; // Run every 600 seconds (10 minutes)
// Generate the XML file
$QWC = new QuickBooks_WebConnector_QWC($name, $descrip, $appurl, $appsupport, $username, $fileid, $ownerid, $qbtype, $readonly, $run_every_n_seconds);
$xml = $QWC->generate();
// Send as a file download
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="my-quickbooks-wc-file.qwc"');
print($xml);
exit;
The URL you're using:
$appurl = 'https://www.domain.com/qb/QuickBooks/SOAP/Server.php';
Is not the right URL.
If you reference the quick start guide you'll note that it has to point the Web Connector to this script:
docs/example_web_connector.php
That is the script that should be in your AppURL. The example script is an actual SOAP endpoint which will allow connections from the Web Connector. You've instead pointed the Web Connector to one of the library files which does nothing on it's own, and which you shouldn't need to touch or reference anywhere.
Incidentally, this is also the reason you've had to add that include_once line as well - you won't need that if you have the Web Connector pointed to the right place.
Related
So, I've downloaded Azure SDK for php and started the emulator. Everything ok.
Then I copy&pasted code from Microsoft, so I can create a new test container.
require_once 'vendor\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
use MicrosoftAzure\Storage\Blob\Models\PublicAccessType;
use MicrosoftAzure\Storage\Common\ServiceException;
// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService('UseDevelopmentStorage=true');
// OPTIONAL: Set public access policy and metadata.
// Create container options object.
$createContainerOptions = new CreateContainerOptions();
// Set public access policy. Possible values are
// PublicAccessType::CONTAINER_AND_BLOBS and PublicAccessType::BLOBS_ONLY.
// CONTAINER_AND_BLOBS:
// Specifies full public read access for container and blob data.
// proxys can enumerate blobs within the container via anonymous
// request, but cannot enumerate containers within the storage account.
//
// BLOBS_ONLY:
// Specifies public read access for blobs. Blob data within this
// container can be read via anonymous request, but container data is not
// available. proxys cannot enumerate blobs within the container via
// anonymous request.
// If this value is not specified in the request, container data is
// private to the account owner.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// Set container metadata.
$createContainerOptions->addMetaData("key1", "value1");
$createContainerOptions->addMetaData("key2", "value2");
try {
// Create container.
$blobRestProxy->createContainer("mycontainer", $createContainerOptions);
} catch (ServiceException $e) {
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/library/azure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code . ": " . $error_message . "<br />";
}
When I run this code, I get a nice error message.
404: Fail:
Code: 404
Value: The specified resource does not exist.
What's wrong with this? I'm running out of ideas. Firstly I had a slightly different code that didn't work either, so now I try to use this sample directly from MS with no luck.
CLI shows that the emulator is running and also that endpoints are correct.
I used Fiddler to capture the http request generated by the SDK, the url path was /testcontainer?restype=container. And according the Rest API guide https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx, the url path should be /devstoreaccount1/mycontainer?restype=container.
Currently, there is a workaround to develop with Azure Storage on local emulator. We can add the local account name devstoreaccount1 every time when we use the container name, e.g.
$blobRestProxy->createContainer("devstoreaccount1/testcontainer");
$blobRestProxy->createBlockBlob("devstoreaccount1/testcontainer", "testblob", "test string");
$blobRestProxy->listBlobs("devstoreaccount1/testcontainer");
Any further concern, please feel free to let me know.
I want to send push notifications to iPhone devices by writing PHP code for it.
gomoob:php-pushwoosh is a PHP Library that easily work with the pushwoosh REST Web Services.
This is the URL for gomoob:php-pushwoosh
As per the instructions I've installed gomoob:php-pushwoosh on my local machine using Composer at location '/var/www/gomoob-php-pushwoosh'
I wrote following code in a file titled sample_1.php which is present at location '/var/www/gomoob-php-pushwoosh/sample_1.php'
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
require __DIR__.'/vendor/autoload.php';
// Create a Pushwoosh client
$pushwoosh = Pushwoosh::create()
->setApplication('XXXX-XXX')
->setAuth('xxxxxxxx');
// Create a request for the '/createMessage' Web Service
$request = CreateMessageRequest::create()
->addNotification(Notification::create()->setContent('Hello Jean !'));
// Call the REST Web Service
$response = $pushwoosh->createMessage($request);
// Check if its ok
if($response->isOk()) {
print 'Great, my message has been sent !';
} else {
print 'Oups, the sent failed :-(';
print 'Status code : ' . $response->getStatusCode();
print 'Status message : ' . $response->getStatusMessage();
}
?>
But I'm getting following error for it :
Fatal error: Class 'Pushwoosh' not found in /var/www/gomoob-php-pushwoosh/sample_1.php on line 9
At the Link they have not mentioned that any file needs to be included into the code. They have only written sample code program. I've used that program as it is but getting error for it.
So can someone please help me in running this program?
The class you want resides in a namespace, so you need to instruct PHP to "import" it (and other classes) from there; add this to the beginning of your script:
use Gomoob\Pushwoosh\Client\Pushwoosh;
use Gomoob\Pushwoosh\Model\Request\CreateMessageRequest;
use Gomoob\Pushwoosh\Model\Notification\Notification;
require __DIR__.'/vendor/autoload.php';
I'm trying to send a text message when a form is submitted using Twilio's test account however I'm receiving the following error: 'Fatal error: Class 'Services_Twilio' not found'
My code is as follows:
} else{
//PHP native
mail( $to_guest, $subject, $html_text, $header_guest);
// Outlet Admin notification email
mail( $to_admin, $subject, $notification_text, $header_admin);
/* Send an SMS using Twilio. You can run this file 3 different ways:
*
* - Save it as sendnotifications.php and at the command line, run
* php sendnotifications.php
*
* - Upload it to a web host and load mywebhost.com/sendnotifications.php
* in a web browser.
* - Download a local server like WAMP, MAMP or XAMPP. Point the web root
* directory to the folder containing this file, and load
* localhost:8888/sendnotifications.php in a web browser.
*/
// Step 1: Download the Twilio-PHP library from twilio.com/docs/libraries,
// and move it into the folder containing this file.
require ('http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php');
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "";
$AuthToken = "";
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
// Step 4: make an array of people we know, to send them a message.
// Feel free to change/add your own phone number and name here.
$people = array(
"+44463463241" => "Andrew Charlton",
);
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$sms = $client->account->messages->sendMessage(
// Step 6: Change the 'From' number below to be a valid Twilio number
// that you've purchased, or the (deprecated) Sandbox number
"YYY-YYY-YYYY",
// the number we are sending to - Any phone number
+44463463241,
// the sms body
"Hey $name, Monkey Party at 6PM. Bring Bananas!"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
}
I've left my account ID and authtoken out of the above.
What is the problem?
so you use require.
According to the documentation and the one of include the require opens a file and evals the code behind it.
what it does in the way you use it, is the following: fetch the file from http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php (whitch returns nothing at all) and evals id (evals nothing).
This is why your require fails.
If you want to require/include that piece of coe, you should download the sourcecode from http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php and put it in the environment of your code.
Bit if i understand Twilio right, they are used as an rest webservice.
Accodring to the documentaton http://www.twilio.com/docs/api/rest/sending-messages
you want to download the rest-client-code (like described here https://www.twilio.com/docs/php/install) and then it all come to you ;-)
I am trying to implement klarna checkout using the codes provided by them here.
Implementing the process as is directed by this link ->
https://docs.klarna.com/en/getting-started
I am using the codes inside docs/examples folder, I have placed the library(src folder) in the proper path have provided the eid and shared secret with the store-ID and Shared secret provided by klarna when I created a test account here.
// Merchant ID
$eid = 'eid';
// Shared secret
$sharedSecret = 'sharedsecret';
I have replaced all the eid and shared scret in all the files and also changed the links in the files properly,
i.e. example.com to mywebsiteurl.com
$create['purchase_country'] = 'SE';
$create['purchase_currency'] = 'SEK';
$create['locale'] = 'sv-se';
$create['merchant']['id'] = $eid;
$create['merchant']['terms_uri'] = 'http://example.com/terms.html';
$create['merchant']['checkout_uri'] = 'http://example.com/checkout.php';
$create['merchant']['confirmation_uri']
= 'http://example.com/confirmation.php' .
'?sid=123&klarna_order={checkout.order.uri}';
// You can not receive push notification on non publicly available uri
$create['merchant']['push_uri'] = 'http://example.com/push.php' .
'?sid=123&klarna_order={checkout.order.uri}';
After setting all things properly, when I click docs/examples/checkout.php I get an exception thrown because the server is responding with an error code. The exception is thrown by BasicConnector.php by the code given below,
* Throw an exception if the server responds with an error code.
*
* #param Klarna_Checkout_HTTP_Response $result HTTP Response object
*
* #throws Klarna_Checkout_HTTP_Status_Exception
* #return void
*/
protected function verifyResponse(Klarna_Checkout_HTTP_Response $result)
{
// Error Status Code recieved. Throw an exception.
if ($result->getStatus() >= 400 && $result->getStatus() <= 599) {
throw new Klarna_Checkout_ConnectorException(
$result->getData(), $result->getStatus()
);
}
}
The error received is
Fatal error: Uncaught exception 'Klarna_Checkout_ConnectorException'
with message '{"http_status_code":500,"http_status_message":"Internal
Server Error","internal_message":""}' in
klarna/docs/examples/src/Klarna/Checkout/BasicConnector.php:212
So my question is this,
Am I not sending a proper request, because I can see the request is
created and no error is given there ?
Can I do anything to get a correct response from the server?
When does a server responds with an error code when cURL request is
made ?
Thank you for your time and help. I really appreciate it.
Well, the solution for such a big question was pretty simple.
Setting the eid="200" and sharedsecret="test". Which are the test account credentials.
In my case I was using my original merchant account credentials.
I'm trying to use Twilio in a Wordpress app and it didn't work, but my same code works in a different site/server.
I added the twilio-php folder and some PHP code to call it inside the wordpress root. I also added code to include it in the existing Wordpress PHP code, and I can't figure it out where the problem is. Can you help?
<?php
require "twilio-php/Services/Twilio.php";
/* Send an SMS using Twilio. You can run this file 3 different ways:
*
* - Save it as sendnotifications.php and at the command line, run
* php sendnotifications.php
*
* - Upload it to a web host and load mywebhost.com/sendnotifications.php
* in a web browser.
* - Download a local server like WAMP, MAMP or XAMPP. Point the web root
* directory to the folder containing this file, and load
* localhost:8888/sendnotifications.php in a web browser.
*/
// Include the PHP Twilio library. You need to download the library from
// twilio.com/docs/libraries, and move it into the folder containing this
// file.
// Set our AccountSid and AuthToken from twilio.com/user/account
$AccountSid = "********************";
$AuthToken = "*********************";
// Instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
/* Your Twilio Number or Outgoing Caller ID */
$from = '**********';
// make an associative array of server admins. Feel free to change/add your
// own phone number and name here.
$people = array(
"*********" => "******",
"**********" => "*********",
);
// Iterate over all admins in the $people array. $to is the phone number,
// $name is the user's name
foreach ($people as $to => $name) {
// Send a new outgoing SMS */
$body = "Hello this is a test message";
$client->account->sms_messages->create($from, $to, $body);
echo "Sent message to $name";
}
?>
i check the server log and notice that curel is not installed in the server then i installed and reboot the server and now it works fine thank you for your great support...Kevin Burke thanx :D