PHP Example for API connection

Andy Simpson Posted in Beginning Developers 6 years ago

I was wondering if someone could please provide me with a working PHP example (full source) of how to interact with the API provided by the OSSN Services component. I have the API key but do not understand how to structure the syntax of my calls to the API.

Thank you

Replies
us MAURICE TAYLOR Replied 10 months ago

I'm horrible with API, so i have a few questions.
Do I have to create a program in order to use API.
if so is it node,js that I use to create an api application, and where do I put it on the server so that APIs can be accessed on my OSSN website. Thank you

Indonesian Arsalan Shah Replied 6 years ago

Andy, this is basic example of work, you can write your own method to utilize this api.

au Andy Simpson Replied 6 years ago

I worked it out, this is how you do it

<?php
$url= 'https://<insert URL/GQDN here>/api/v1.0/user_details?api_key_token=<insert your API key here>&guid=1';

$arrContextOptions=array(
      "ssl"=>array(
            "verify_peer"=>false,
            "verify_peer_name"=>false,
        ),
    );

$response = file_get_contents($url, false, stream_context_create($arrContextOptions));
echo "<pre>";
print_r($response);
echo "</pre>";
?>
us David Vaccaro Replied 6 years ago

I would like that too.