【问题标题】:twinfield API integration with laraveltwinfield API 与 laravel 的集成
【发布时间】:2018-01-10 03:06:43
【问题描述】:

Twinfield 是一个面向中小型企业的在线财务会计软件包,由位于荷兰的 Twinfield International 生产和维护。它被 20 个国家的 15,000 多名用户使用。

我想集成它的 API。我已经安装了 laravel 并创建了一些基本的 API,但它非常庞大。集成示例如何以及在何处链接?请帮我。

【问题讨论】:

标签: php laravel twinfield


【解决方案1】:

这不是完整的代码,但为您提供了双域的登录名。我也被卡住了,因为为 twinfield 提供了许多库,但没有提供任何示例代码。没有提供 PHP 集成的文档。我对双场感到非常失望。即使您有测试帐户并且它会禁用而不是永久禁用。这里的 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;
    }

link 中也给出了一些代码。您将通过https://github.com/php-twinfield/twinfield 集成它,但您必须做很多工作。我也在努力,如果有什么需要请告诉我。

【讨论】:

  • 这真是太棒了,而且很有效。我得到了会话ID。非常感谢,如果有任何其他代码,请给我。
  • 请注意,这将很快被弃用,因为 Twinfield 将删除密码身份验证。
  • 所以@Alex:你能提供新的 oaurh 登录名或其他代码吗?
猜你喜欢
  • 2021-07-28
  • 2019-01-16
  • 1970-01-01
  • 2021-01-06
  • 1970-01-01
  • 2015-05-01
  • 2021-04-29
  • 2020-12-13
  • 2020-10-19
相关资源
最近更新 更多