knoxguru / nsbundle
在您的Symfony应用程序中访问NS PHP Toolkit API
dev-master
2014-04-18 03:10 UTC
Requires
- php: >=5.3.2
This package is not auto-updated.
Last update: 2024-09-28 15:08:26 UTC
README
Netsuite PHP Toolkit包用于Symfony2应用程序。原始源代码和示例可以在以下地址找到:http://www.netsuite.com/portal/developers/resources/suitetalk-sample-applications.shtml
原始作品及其许可协议位于src/KnoxGuru/bundle/NSBundle/NS文件夹中。
#安装
使用composer添加以下行到您的require部分
"knoxguru/nsbundle": "dev-master"
然后
composer.phar update
将bundle添加到您的AppKernel.php文件中
new KnoxGuru\Bundle\NSBundle\KnoxGuruNSBundle(),
接下来,您需要将这些参数复制粘贴到您的app/config/config.yml文件中,并适当修改它们
parameters:
/*...*/
knoxguru.nsendpoint: "2013_2"
knoxguru.nshost: "https://webservices.netsuite.com"
knoxguru.nsemail: "jDoe@yourdomain.com"
knoxguru.nspassword: "mySecretPwd"
knoxguru.nsrole: "3"
knoxguru.nsaccount: "MYACCT1"
我尚未测试2014_1版本,但从目前的情况来看,我预计不会有太大问题。我将在能够的时候重新关注2014_1版本。
#使用
$this->container->get('knoxguru.nsservice');
在控制器内部,使用此命令进行初始化
use KnoxGuru\Bundle\NSbundle\NetSuiteService;
use KnoxGuru\Bundle\NSbundle\GetRequest;
use KnoxGuru\Bundle\NSbundle\RecordRef;
class MyController extends Controller {
public function indexAction() {
$this->container->get('knoxguru.nsservice');
$service = new NetSuiteService();
$request = new GetRequest();
$request->baseRef = new RecordRef();
$request->baseRef->internalId = "21";
$request->baseRef->type = "customer";
$getResponse = $service->get($request);
if (!$getResponse->readResponse->status->isSuccess) {
echo "GET ERROR";
} else {
$customer = $getResponse->readResponse->record;
echo "GET SUCCESS, customer:";
echo "\nCompany name: ". $customer->companyName;
echo "\nInternal Id: ". $customer->internalId;
echo "\nEmail: ". $customer->email;
}
}
}
初始化后,您可以通过将其添加到uses中在任何地方使用这些类
进一步阅读
您可以在以下位置找到工具包文档:http://tellsaqib.github.io/NSPHP-Doc/index.html