@@ -651,23 +651,23 @@ public function create($data = null, $portal = null, $script = null)
651651 */
652652 public function duplicate ($ recordId , $ script = null )
653653 {
654- try {
655- if ($ this ->restAPI ->login ()) {
656- $ request = "{} " ; //FileMaker expects an empty object, so we have to set "{}" here
657- $ headers = ["Content-Type " => "application/json " ];
658- $ params = ['layouts ' => $ this ->layout , 'records ' => $ recordId ];
659- if (!is_null ($ script )) {
660- $ request = $ this ->buildScriptParameters ($ script );
661- }
662- $ this ->restAPI ->callRestAPI ($ params , true , 'POST ' , $ request , $ headers );
663- $ this ->restAPI ->storeToProperties ();
664- $ this ->restAPI ->logout ();
665- } else {
666- return null ;
667- }
668- } catch (\Exception $ e ) {
669- throw $ e ;
670- }
654+ try {
655+ if ($ this ->restAPI ->login ()) {
656+ $ request = "{} " ; //FileMaker expects an empty object, so we have to set "{}" here
657+ $ headers = ["Content-Type " => "application/json " ];
658+ $ params = ['layouts ' => $ this ->layout , 'records ' => $ recordId ];
659+ if (!is_null ($ script )) {
660+ $ request = $ this ->buildScriptParameters ($ script );
661+ }
662+ $ this ->restAPI ->callRestAPI ($ params , true , 'POST ' , $ request , $ headers );
663+ $ this ->restAPI ->storeToProperties ();
664+ $ this ->restAPI ->logout ();
665+ } else {
666+ return null ;
667+ }
668+ } catch (\Exception $ e ) {
669+ throw $ e ;
670+ }
671671 }
672672
673673 /**
@@ -1677,11 +1677,15 @@ public function __construct($solution, $user, $password, $host = null, $port = n
16771677 * @return string
16781678 * @ignore
16791679 */
1680- public function getURL ($ params , $ request , $ methodLower , $ isSystem = false )
1680+ public function getURL ($ params , $ request , $ methodLower , $ isSystem = false , $ directPath = false )
16811681 {
16821682 $ vStr = $ this ->vNum < 1 ? 'Latest ' : strval ($ this ->vNum );
1683- $ url = "{$ this ->protocol }:// {$ this ->host }: {$ this ->port }/fmi/data/v {$ vStr }" .
1684- ((!$ isSystem ) ? "/databases/ {$ this ->solution }" : "" );
1683+ $ url = "{$ this ->protocol }:// {$ this ->host }: {$ this ->port }" ;
1684+ if ($ directPath ) {
1685+ $ url .= $ directPath ;
1686+ } else {
1687+ $ url .= "/fmi/data/v {$ vStr }" . ((!$ isSystem ) ? "/databases/ {$ this ->solution }" : "" );
1688+ }
16851689 foreach ($ params as $ key => $ value ) {
16861690 $ url .= "/ {$ key }" . (is_null ($ value ) ? "" : "/ {$ value }" );
16871691 }
@@ -1949,21 +1953,58 @@ public function logout()
19491953 }
19501954 }
19511955
1956+ private function getSupportingProviders ()
1957+ {
1958+ try {
1959+ $ this ->callRestAPI ([], [], 'GET ' , [], [], false , "/fmws/oauthproviderinfo " );
1960+ $ result = [];
1961+ foreach ($ this ->responseBody as $ key => $ item ) {
1962+
1963+ }
1964+ return $ result ;
1965+ } catch (\Exception $ ex ) {
1966+ return null ;
1967+ }
1968+ }
1969+
1970+ private function getOAuthIdentifier ($ provider )
1971+ {
1972+ try {
1973+ $ this ->callRestAPI ([], [
1974+ "trackingID " => rand (10000000 ,99999999 ),
1975+ "provider " => $ provider ,
1976+ "address " => "127.0.0.1 " ,
1977+ "X-FMS-OAuth-AuthType " => 2
1978+ ], 'GET ' , [], [
1979+ "X-FMS-Application-Type " => 9 ,
1980+ "X-FMS-Application-Version " => 15 ,
1981+ "X-FMS-Return-URL " => "http://127.0.0.1/ " ,
1982+ ], false , "/oauth/getoauthurl " );
1983+ $ result = [];
1984+ foreach ($ this ->responseBody as $ key => $ item ) {
1985+
1986+ }
1987+ return $ result ;
1988+ } catch (\Exception $ ex ) {
1989+ return null ;
1990+ }
1991+ }
1992+
19521993 /**
19531994 * @param $params
19541995 * @param $layout
1955- * @param $isAddToken
1996+ * @param boolean $isAddToken
19561997 * @param string $method
1957- * @param null $request
1958- * @param null $recordId
1959- * @param false $isSystem for Metadata
1998+ * @param array $request
1999+ * @param array $addHeader
2000+ * @param boolean $isSystem for Metadata
19602001 * @throws Exception In case of any error, an exception arises.
19612002 * @ignore
19622003 */
1963- public function callRestAPI ($ params , $ isAddToken , $ method = 'GET ' , $ request = null , $ addHeader = null , $ isSystem = false )
2004+ public function callRestAPI ($ params , $ isAddToken , $ method = 'GET ' , $ request = null , $ addHeader = null , $ isSystem = false , $ directPath = false )
19642005 {
19652006 $ methodLower = strtolower ($ method );
1966- $ url = $ this ->getURL ($ params , $ request , $ methodLower , $ isSystem );
2007+ $ url = $ this ->getURL ($ params , $ request , $ methodLower , $ isSystem, $ directPath );
19672008 $ header = $ this ->getHeaders ($ isAddToken , $ addHeader );
19682009 $ jsonEncoding = true ;
19692010 if (is_string ($ request )) {
@@ -2049,7 +2090,7 @@ public function callRestAPI($params, $isAddToken, $method = 'GET', $request = nu
20492090 $ description = date ('Y-m-d H:i:s ' ) . "{$ description }" ;
20502091 $ description .= "[URL( {$ this ->method }): {$ this ->url }] " ;
20512092 if ($ errorCode !== 401 ) {
2052- throw new \Exception ($ description , $ errorCode );
2093+ throw new \Exception ($ description , $ errorCode );
20532094 }
20542095 }
20552096 }
0 commit comments