I am not certain if I am maybe misunderstanding, something in the examples I see, but any time I try to make sure of nsComplexObject, I get an error that it does not exist.
I am specifically trying to create a sales order. I set up my array of values, but when I try to do the following, I get an error:
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$salesOrder = new nsComplexObject('SalesOrder');
?>
I think you're looking at older Toolkit examples.
The newer versions (I think since 2012_2) use a different method for instantiating objects, such as:
$salesOrder = new SalesOrder();
You can still use the setFields method to populate object properties, but you can also populate them directly now:
$salesOrder->entity = $someRecordRefObject;
Related
I've been dealing with the Laravel/Osiset-Shopify framework for some time and even after a long research there are things that I don't understand yet.
For example, if I want to fetch my webhooks, it is relatively cumbersome
Auth::user()->api()->rest('GET', '/admin/api/2021-04/webhooks.json')['body']
There is a function getWebhooks() under \osiset\laravel-shopify\src\ShopifyApp\Services\ApiHelper.php which I would much rather use.
I came across this documentation from Osiset, for which I don't know how to use it.
I tried to load the service use Osiset\ShopifyApp\Services\ApiHelper; and get the output data dd(ApiHelper::getWebhooks([]));. However, I get the error message Non-static method Osiset\ShopifyApp\Services\ApiHelper::getWebhooks() cannot be called statically.
Also
$foo = new ApiHelper;
dd( $foo->getWebhooks() );
did not lead to any result: Call to a member function rest() on null.
Can someone show me how to access Osiset's internal functions and use the documentation properly?
You can use this documentation
and for the webhooks.json, You can use this to get the results $userId will be the user's primary key.
$shop = User::find($userId);
$method = 'GET';
$url = '/admin/api/2021-04/webhooks.json';
return $shop->api()->rest($method, $url, []);
I need write a customlog on laravel 5.3, and modify on runtime for add some extra information.
So far I have managed to do it, but the code does not work because what I can do is add a new instance of the log, which duplicates the lines in each modification of the format.
My handicap is that I do not know how to return or if this is possible, the current handler of the logging system, and simply pass it the format modification.
The code below allows me to modify the format line, but only once.
If I run it again, start duplicating the lines, and what is not like, create the handler in another way, or use the existing one that would be appropriate.
$maxFiles = config('app.log_max_files');
$path = storage_path('/logs/cprsync.log');
// Really I don't need this because this are on Laravel App, but with this method y can create a $handler for modify format
$handler = new RotatingFileHandler($path, is_null($maxFiles) ? 5 : $maxFiles, config('app.log_level'));
(is_null(config('cprsync.activejob'))) ? $job = '' : $job=' ['.config('cprsync.activejob').']';
$logFormat = "[%datetime%] [%level_name%]".$job.": %message% %context% %extra%\n";
$formatter = new LineFormatter($logFormat,null,true,true);
$handler->setFormatter($formatter); // What I really want is to make this change ...
// Push handler
$log->getMonolog()->pushHandler($handler);
I don't know if it's the prettiest (like in Symfony you can just put some YAML rules in the services.yml and you've changed your log format), but this seems to be a very valid option and basically builds on what you're doing already:
http://laravel-tricks.com/tricks/monolog-for-custom-logging
TL;DR: Create a custom logging class with a function write() that basically contains the code OP has posted. Then add that class to your facades and you can log with MyCustomLogger::write($message);
EDIT: This isn't really what OP requested, since this doesn't change the format on runtime.
After much of a struggle I managed to install MongoDB as a service and WAMP. Then on start I got a fatal error saying these would not work:
$m = new Mongo(...);
$m = new MongoClient(...);
In some previous questions on SO people mentioned using a new class called MongoDB/Driver/Manager. I also came across something called MongoDB/Client.
As a beginner to MongoDB I now stand rather confused about how to use/connect to a DB and collection.
I guess I will use:
$m = new MongoDB/Driver/Manager(...);
However,
$db = $m->$dbname; // Seems to cause -> Notice: Undefined Property
$collection = $db->shows; // dito
So all in all what are the difference between MongoDB/Driver/Manager and MongoDB/Client ? And with these new classes how would I correctly connect to a DB or Collection as shown in the previous snippet ? I can't seem to find many examples explaining how to use these new classes, or an up to date correct way of using the new classes for basic functionality.
Thanks,
I think I understand what I am confusing.
Using the MongoDB/Driver/Manager class and others, are part of the basic tools available with the PHP MongoDB Driver. I am guessing it is not recommended using them unless you know what you are doing, or you want something relatively customized.
A more recommendable alternative is to install "mongodb/mongodb-^1.x.x" with a PHP installer such as Composer, which will give you a MongoDB Library. This will give you classes such as the MongoDB/Client class.
Once the library has been installed you can connect like so:
<?php
require 'vendor/autoload.php';
$client = new MongoDB/Client('mongodb://localhost:27017');
// Add URI of MongoDB here
$mydb = $client->mydb; // Add the new DB name or existing DB name here
$collection = $mydb->createCollection('userCollection');
...
?>
I've worked on this for about 4 hours and I am real close but just missing the mark – here is what xml needs to look like
<ws:Answer QuestionID="Q_CAM_ID" ws:Datatype="string">
<ws:Value>6838</ws:Value>
</ws:Answer>
Here is what I get
<ns1:Answer QuestionID="Q_CAM_ID">
<ns1:Value>6838</ns1:Value>
</ns1:Answer>
Using
$A1 = new StdClass();
$A1->QuestionID = 'Q_CAM_ID';
$A1->Value =6838;
No matter what I try I can’t get “ws:Datatype="string"” to appear. I believe the answer is the below or real similar
$A1 = new StdClass();
$A1->QuestionID = new StdClass();
$A1->QuestionID->QuestionID ='Q_CAM_ID';
$A1->QuestionID->DataType ='string';
$A1->Value =6838;
But what I keep getting is this error
Catchable fatal error Object of class stdClass could not be converted to string when the soap call is done. If anyone has a clue I would be most appreciative
The simliest way to do it is to use a WSDL to php generator as you'll only deal with PHP object that matches the requires types. Moreover, if you a good WSDL to php generator, you'll have PHP classes that are named as the elements.
You could use https://www.wsdltophp.com or https://github.com/mikaelcom/WsdlToPhp.
Maybe I'm missing something but if you need that XML why not just make it as a String, and then convert it to what you are trying to do? If you are not using a WSDL or SimpleXML, I would just do the following.
$xml =
'
<ws:Answer QuestionID="Q_CAM_ID" ws:Datatype="string">
<ws:Value>6838</ws:Value>
</ws:Answer>
';
I have been struggling with the php api for Google Calendar for weeks now.
I have already managed to add and read events with the api and now I'm trying to get Extended Properies to work. I have tried two different ways of adding them to my events:
1:
$extProp = New Google_EventExtendedProperties('test', 'test');
$event->setExtendedProperty($extProps);
2:
$extProp = New Google_EventExtendedProperties('test', 'test');
$event->ExtendedProperty = $extProps;
Both don't give me errors, but I'm not sure if it's working. I tried to read the events with the get method as well as with the list method wich are both described in the documentation of the api, but I can't get my extended properties.
Does anyone know how extended properties work with php?
I finally managed to do it. I used the following code:
$extendedProperties = New Google_EventExtendedProperties();
$extendedProperties->setShared(array('custom'=>'blalblabla'));
$event->setExtendedProperties($extendedProperties);
$extendedProperties = New Google_EventExtendedProperties();
should be changed to:
$extendedProperties = new Google_Service_Calendar_EventExtendedProperties();