QuickBooks PHP Sdk "Use" Causes Fatal Error - php

I am using the SDK and _Sample files to test a simple invoice creation.
I am not using composer, so the sample tells me to do this....
include('../config.php');
use QuickBooksOnline\API\Core\ServiceContext;
use QuickBooksOnline\API\DataService\DataService;
use QuickBooksOnline\API\PlatformService\PlatformService;
use QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer;
use QuickBooksOnline\API\Facades\Invoice;
$dataService = DataService::Configure(array(
'auth_mode' => 'oauth1',
'consumerKey' => "qyprdUSoVpIHrtBp0eDMTHGz8UXuSz",
'consumerSecret' => "TKKBfdlU1I1GEqB9P3AZlybdC8YxW5qFSbuShkG7",
'accessTokenKey' => "qyprdxccscoNl7KRbUJoaJQIhUvyXRzD9tNOlXn4DhRDoj4g",
'accessTokenSecret' => "JqkHSBKzNHbqjMq0Njbcq8fjgJSpfjMvqHVWnDOW",
'QBORealmID' => "193514464689044",
'baseUrl' => "Development"
));
So i have done this on my website, but I get the following error...
ParseError: syntax error, unexpected 'use' (T_USE)
I've literally copied the code above, into a new php file. I have successfully loaded the config.php file.
I have seen elsewhere that a "use" statement must be at the top of the file... it is!

Related

Uncaught Error: Class 'Discord\Client' not found PHP

I am working with Php and "Discord". Right now, I am getting the following error:
Fatal error: Uncaught Error: Class 'Discord\Client' not found",But in my "src folder
Client library exists, I have "Vendor" and "src" folders, and client.php is there. Here is my code - where I am going wrong?
<?php
include __DIR__.'/vendor/autoload.php';
include 'vendor/autoload.php';
use Discord\Discord;
use Discord\Parts\Interactions\Command\Command; // Please note to use this correct namespace!
use Discord\Client;
use Discord\Parts\Interaction;
use Discord\Parts\Choices;
$client = new Client([
'public_key' => 'b81678ce3e98ff78f9387c3cxxxxxxxxxxxxxxxx',
'uri' => '0.0.0.0:80', // if you want the client to listen on a different URI
'logger' => $logger, // different logger, default will write to stdout
'loop' => $loop, // reactphp event loop, default creates a new loop
'socket_options' => [], // options to pass to the react/socket instance, default empty array
]);
You need to use
$client = new Discord([
'token' => 'b81678ce3e98ff78f9387c3cxxxxxxxxxxxxxxxx'
]);
Instead of client because library team-reflex/discord-php using Discord class instead of Client in direct interaction.
Here you can find the use cases.

ClientID Must Be Provided

I'm attempting to add a new bill using the quickbooks API, and I have downloaded the source code and have filled out the $dataservice array. It looks like :
$dataService = DataService::Configure(array(
'auth_mode' => 'oauth2',
'ClientID' => $config[CLIENTID],
'ClientSecret' => $config[CLIENTSECRET],
'RedirectURI' => $config['https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl'],
'scope' => $config['com.intuit.quickbooks.accounting'],
'baseUrl' => "production"
));
With CLIENTID and CLIENTSECRET obviously being the real keys that are generated from my Intuit Developer Account. When I run the php file by going directly to it I get two errors
Fatal error: Uncaught QuickBooksOnline\API\Exception\SdkException: [0]: 'ClientID' must be provided in C:\wamp64\www\Bill\vendor\quickbooks\v3-php-sdk\src\Core\ServiceContext.php on line 205
and
QuickBooksOnline\API\Exception\SdkException: 'ClientID' must be provided in OAuth2. in C:\wamp64\www\Bill\vendor\quickbooks\v3-php-sdk\src\Core\ServiceContext.php on line 205
But as seen above I have set the ClientID. Is there a different way I'm supposed to Access the php file, or is there another config file that should have ClientID set?
Not sure if it's necessary info but I installed the Quickbooks SDK with Composer

Postmarkapp sending email using template PHP class

I am trying to send a email using postmarkapp api in php, I have managed to get it to send plain emails. I have uploaded the class to the same directory as index.php but the 'use' function seems to give me a error which is out of my knowledge.
Error:
Parse error: syntax error, unexpected '.', expecting identifier (T_STRING) in /public_html/index.php on line 5
Index.php
// Import the Postmark Client Class.
use Postmark\Models\PostmarkAttachment;
use Postmark\PostmarkClient\.php;
// Create Client
$client = new PostmarkClient("MY API KEY - CENSORED");
// Make a request
$sendResult = $client->sendEmailWithTemplate(
"sender#example.com",
"recipient#example.com",
TEMPLATEID-CENSORED,
[
"product_name" => "product_name_Value",
"name" => "name_Value",
"action_url" => "action_url_Value",
"username" => "username_Value",
"sender_name" => "sender_name_Value",
"product_address_line1" => "product_address_line1_Value",
"product_address_line2" => "product_address_line2_Value",
]);
Same directory Postmark/ I have this class (official class)
https://github.com/wildbit/postmark-php/tree/master/src/Postmark
Thanks for taking the time to read, greatly appreciated.
I think you need 'use Postmark\PostmarkClient;' instead of 'use Postmark\PostmarkClient.php;'

How do I `use` a namespace in Yii and HAML?

I'm using MTHAML and Yii. I have the following lines.
-use yii\helpers\Url
%a{:href => Url::toRoute(['shopping/ping', 'id' => (string)$item->productId, 'category' => (string)$item->primaryCategory->categoryId])} test
However it gives an error.
syntax error, unexpected 'use' (T_USE)
<?php
function __MtHamlTemplate_65307eb071e28021db686cb46d491c8faae477235051858b05f212731637dd40($__variables)
{
extract($__variables);
?><?php use yii\helpers\Url; ?>
I am fixed this bug today.
Update your package by running:
composer update
or download latest release 0.1.3 from GitHub
Because of the namespace invalid when compile html cached.
Please try this from root nb
%a{:href => \yii\helpers\Url::toRoute(['shopping/ping', 'id' => (string)$item->productId, 'category' => (string)$item->primaryCategory->categoryId])} test

Parse Error: Zend_Oauth::REQUEST_SCHEME_HEADER Error: Unexpected ',' while expecting '('

Using PHP GMail OAuth Library/Sample.
$options = array(
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
'version' => '1.0',
'consumerKey' => $THREE_LEGGED_CONSUMER_KEY,
'callbackUrl' => getCurrentUrl(),
'requestTokenUrl' => 'https://www.google.com/accounts/OAuthGetRequestToken',
'userAuthorizationUrl' => 'https://www.google.com/accounts/OAuthAuthorizeToken',
'accessTokenUrl' => 'https://www.google.com/accounts/OAuthGetAccessToken'
);
Here's the error: Parse error: syntax error, unexpected ',', expecting '('
This is from line 77: the 'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER, line, any ideas?
Edit: I'm using PHP 4.4.8
You're using PHP 4, which does not support class constants; when it sees code like that, it's expecting a static function call, which it does support:
Class::static_function()
However, in the case of your code, the Zend_Oauth class has a const REQUEST_SCHEME_HEADER, a PHP 5-only feature, which is accessed like so:
Zend_Oauth::REQUEST_SCHEME_HEADER
This is why Zend Framework requires PHP 5. If you intend to use it, yes you'll need to contact your hosting provider to see if they offer PHP 5 as an option or something.
It looks like you are running PHP4.
Most likely your server has both php5 and php4 installed, but it defaults to php4. Contact your server provider.

Categories