![](/img/trans.png)
[英]Twinfield API OAuth2.0 getaccessToken php-twinfield/twinfield
[英]twinfield API integration with laravel
Twinfield是由荷蘭Twinfield International生產和維護的中小型企業在線財務會計軟件包。 有20個國家的15,000多個訂戶使用。
我想集成其API。 我已經安裝了laravel並創建了一些基本的API,但是它很大。 集成示例如何鏈接以及在何處鏈接? 請幫我。
這不是完整的代碼,但可以讓您登錄twinfield。 我也很困惑,因為為twinfield提供了許多庫,但沒有提供任何示例代碼。 沒有提供PHP集成的文檔。 我對Twinfield感到非常失望。 即使您擁有測試帳戶,該帳戶也會被禁用,而永久禁用。 這里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;
}
此鏈接中也提供了一些代碼。 您將通過https://github.com/php-twinfield/twinfield集成它,但是您需要做很多工作。 我也在努力,如果您需要任何幫助,請告訴我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.