简体   繁体   English

twinfield API与laravel集成

[英]twinfield API integration with laravel

Twinfield is an online financial accounting software package for small and medium enterprises, produced and maintained by Twinfield International, based in The Netherlands. Twinfield是由荷兰Twinfield International生产和维护的中小型企业在线财务会计软件包。 It is used by over 15,000 subscribers in 20 countries. 有20个国家的15,000多个订户使用。

I want to integrate its API. 我想集成其API。 I have install laravel and create some basic API, but its huge. 我已经安装了laravel并创建了一些基本的API,但是它很大。 How and where the integration example links? 集成示例如何链接以及在何处链接? Please help me. 请帮我。

This is not the full code but gives you the login for the twinfield. 这不是完整的代码,但可以让您登录twinfield。 I am also stuck because many libraries are given for twinfield but not give any sample code for it. 我也很困惑,因为为twinfield提供了许多库,但没有提供任何示例代码。 There is no document provide for PHP integration. 没有提供PHP集成的文档。 I am very disappointed with twinfield. 我对Twinfield感到非常失望。 Even if you have test account and it will disable than it will permanent disable. 即使您拥有测试帐户,该帐户也会被禁用,而永久禁用。 Here the jsonresponse is custom made so you can call only $e->getMessage() if you have any error related it. 这里jsonresponse是自定义的,因此如果与它相关的任何错误都只能调用$ e-> getMessage()

public function login(\Illuminate\Http\Request $request){
        $user = $request->input('user');
        $password = $request->input('password');
        $org = $request->input('organisation');

        $params = array(
            'user' => $user,
            'password' => $password,
            'organisation' => $org 
        );
        // login => Set the param array and send to the logon
        try
        {
            $session = new \SoapClient("https://login.twinfield.com/webservices/session.asmx?wsdl", array('trace' => 1));
            $result = $session->logon($params);
            // echo '<pre>';print_r($result);
            $cluster = $result->cluster;
            $qq = new domDocument();
            $qq->loadXML($session->__getLastResponse());
            $sessionID = $qq->getElementsByTagName('SessionID')->item(0)->textContent;
            //echo $sessionID;
            $newurl = $cluster . '/webservices/processxml.asmx?wsdl';
            try
            {
                $client = new \SoapClient($newurl);
                $data = new \SoapHeader('http://www.twinfield.com/', 'Header', array('SessionID'=> $sessionID));
                $jsonResponse = JsonResponse::success($data);
            }
            catch (SoapFault $e)
            {
                $jsonResponse = empty($e->getMessage()) ? JsonResponse::error(class_basename($e)) : JsonResponse::error($e->getMessage());
            }
        }
        catch (SoapFault $e)
        {
            $jsonResponse = empty($e->getMessage()) ? JsonResponse::error(class_basename($e)) : JsonResponse::error($e->getMessage());
        }
        return $jsonResponse;
    }

Some code are given in this link too. 链接中也提供了一些代码。 You will integrate it via https://github.com/php-twinfield/twinfield but you have to work a lot. 您将通过https://github.com/php-twinfield/twinfield集成它,但是您需要做很多工作。 I am also working on it, if anything you need plz let me know. 我也在努力,如果您需要任何帮助,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM