Android Question Php & API Implementation

DerpCode

Member
Hi, I'm attempting to figure out how to implement an API in an app I'm designing. I'm having trouble using the PHP Code provided. It's a JSON and the api is called api medic.

Has anyone implemented PHP based api? I'm attempting to use a symptom checker in the app.
 

DerpCode

Member
Hi mcqueccu,

I'm attaching the PHP code provided by the APIMedic team. I'm not too sure where to fit the blocks of the puzzle to acheive something like API.

I haven't done any programming in quite a while so it's quite complicated for me to just smack this into an app, but basically I've created relevant panel on the designer, generated members now I'm wondering how I'm suppose to code it so for example, how do I send the user information I'm going to collect to the server to get a diagnosis.

I hope that makes some sense?
 

Attachments

  • php.zip
    4 KB · Views: 285
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
1.- Token (class TokenGenerator):

you must first generate the token to access the diagnostics

PHP:
            $computedHash = base64_encode(hash_hmac ( 'md5' , $this->authServiceUrl , $this->password, true ));
            $authorization = 'Authorization: Bearer '.$this->username.':'.$computedHash;
         
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, '');
            curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
            curl_setopt($curl, CURLOPT_URL, $this->authServiceUrl);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

2.- priaid_client (class DiagnosisClient)
 
Last edited:
Upvote 0

DerpCode

Member
I've got the Auth token & url
 
Upvote 0

DerpCode

Member
Where is the API description.?

The PHP is doing CURL calls. So you should be able to do it directly with B4X and use okhttputils2 to communicate with the Api.
What kind of API description? Could you eleborate? I have documentation for it if that's what you were asking for?
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
tips:

It is similar to your case, you can guide it

 
Upvote 0

DerpCode

Member
I'm just attempting to grasp what help you've given, with the articles are we attempting to use similar information and communicate with the API medic website?

I belive in that guide his trying to securely communicate with the webpage which would be similar to me. Would this mean his final solution is what I should be looking to use for mine in order to properly communicate with APIMedic? If that is the case, where would I obtain my API key secret? I've only been given Api url/token username & pw.
 
Upvote 0

DerpCode

Member
I'm going to do some examples of these, as I'm interested in what I've seen of these APIs.

we have some APP in the medical area.
This would be great, I'd like to see how you go about implementing this as this is my first time dealing with API. Seems like it's a very massive undertaking, so I'd like to check by example
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I have documentation for it if that's what you were asking for?
yes

I did find
but no documentation; even not in their website after registration for a free account.
I can get api key but i did not found any Documentation.

The api is based on REST; should be easy to do it with B4X
 
Upvote 0

DerpCode

Member
you will find it under. 'API keys' tab. There will be 4 types of documentation. 2 for Live Data and 2 for Dummy
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…