Jump to content

CURL question - API usage


This topic is 2348 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Good morning.

I am trying to use FM16 to extract data through an API. It requires an API key and string to be sent, but don't see where in the "Insert from URL" syntax how it can be applied - I think I have the rest of the syntax working ok though.

The PHP syntax (according to the host support team) say it is:
$curl =
getCurl($id, $key, $signature, $endpoint, $requestUrl, $format);

I have all the details (I'm pretty sure) except the signature. I'm trying to use the native FM16 functions if possible - just to minimise third party products (although BaseElements may be OK)

Could somebody please give me a clue as to the correct syntax I should be using?  I'm happy to engage (and pay for) the services of somebody for a hour or two to sort this out for me. (I hope Im not breaking any forum rules here by doing this - I'll remove this if I am)


Thank you in advance.

Greg

 

Edited by Greg Hains
Link to comment
Share on other sites

I'm not familiar with the getCurl function in php, and a google search didn't seem to show it as a common function. I'm guessing it's an application specific function, which means that without a link to documentation, what you've said so far is not helpful in resolving your issue.

Can you provide links to published documentation for the API you're trying to access? If not, can you provide any more details about the API at all? If not, I think you'll find little help here; unless I'm missing something obvious.

Without more information from you, the only advice I can offer is to use https://httpbin.org/ and possibly http://oauthbin.com/ to debug your http requests.

Link to comment
Share on other sites

Hi Dan,

Thank you for responding.

The API documentation I have been working through (not to mentioned the countless examples and Googled pages on CURL in general over the last 48 hours) is at https://apidocs.unleashedsoftware.com/.  There is an API Key and an API ID (which, with all due respect, I cannot post publicly as it is for my client) issued by Unleashed - both of them longish alphanumeric strings.  

I was hoping to get more info about the raw text string sent to Unleashed's API sandbox (even if I used Wireshark. lol), but I was hoping there was a "standard" that may be used that would incorporate the likes of API keys. I realise to that this is a proprietary thing and probably not a general forum question, but thought there maybe a glimmer of hope in finding a solution.

I will check out those websites you mentioned - thank you

 Cheers,
Greg

 

Edited by Greg Hains
Link to comment
Share on other sites

13 minutes ago, Greg Hains said:

There is an API Key and an API ID (which, with all due respect, I cannot post publicly as it is for my client).

Nobody would expect you to and I'm glad you didn't.

13 minutes ago, Greg Hains said:

I was hoping there was a "standard" that may be used that would incorporate the likes of API keys.

Yes, there are some standards, but the bottom line is you need to follow the rules defined by the API you're trying to access. In this case, the authentication is documented here: https://apidocs.unleashedsoftware.com/AuthenticationHelp which states you need  an HMAC-SHA256 signature, which can be created in FM16 via https://fmhelp.filemaker.com/help/16/fmp/en/#page/FMP_Help%2Fcryptauthcode.html. It also states you'll need to set some HTTP headers, which again can be done in FM16: https://fmhelp.filemaker.com/help/16/fmp/en/#page/FMP_Help%2Fcurl-options.html.

If this type of work isn't something you want to deal with, I could be hired to do it for you. In you're interested in that, please send me a private message.

Link to comment
Share on other sites

Thanks Dan.

I have made further enquiries with the hosted service regarding the API syntax etc. I hope to hear back from them soon.
I've sent you a private message with more details.

Thanks,
Greg

 

Link to comment
Share on other sites

I started a trial account for testing and was able to get it to work. I did end up needing to use the BaseElements plugin, but only in one special circumstance, which I documented in the only script in the file. The issue was that FileMaker's CryptAuthCode function returns an empty value if you send it empty data, but that's not what the Unleashed API expects. Luckly, BaseElement's did return data, even if you send it an empty value, so I used it only when necessary.

To use the attached file, open the Call API script and add your $apiId and $apiKey. Then on the Layout, you can use the buttons in the header to send two sample requests. Each time you click one of those buttons it will send the request to the API, and record it in a new record.

 

Unleashed API.fmp12

Link to comment
Share on other sites

Hi Dan,

Thankyou for this file. It looks great.
I have sent you a private PM through FmForums as well.

I have been also working with the provider in regards to the exact syntax they require. I probably wont hear back over the weekend but will get back to you once they do.

Thanks for your help and look forward to working further on this question.

Greg
 

Link to comment
Share on other sites

This topic is 2348 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.