0

Twinfield is an online financial accounting software package for small and medium enterprises, produced and maintained by Twinfield International, based in The Netherlands. It is used by over 15,000 subscribers in 20 countries.

I want to integrate its API. I have install laravel and create some basic API, but its huge. How and where the integration example links? Please help me.

  • Question for Twinfield support I'd say. Go through [documentation](https://c3.twinfield.com/webservices/documentation/#/Welcome) first and check what they offer [out of the box](https://c3.twinfield.com/webservices/documentation/#/CodeExamples). – Tpojka Nov 24 '17 at 11:00

1 Answers1

-1

This is not the full code but gives you the login for the twinfield. I am also stuck because many libraries are given for twinfield but not give any sample code for it. There is no document provide for PHP integration. I am very disappointed with 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.

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. I am also working on it, if anything you need plz let me know.

Anand Pandey
  • 2,025
  • 3
  • 20
  • 39
  • This is jsut awesome and working. I get the session id. Thank you very much and please give me if any other code for this. –  Dec 22 '17 at 06:17
  • Please note that this will be deprecated soon as Twinfield will remove password authentication. – Alex Jan 09 '18 at 19:06
  • So @Alex: can you give the new oaurh login or other code for that? – Anand Pandey Jan 15 '18 at 12:58