Friday 31 January 2020

Consume Get API

Consume get API from ASP.Net using PHP


This post will help you to know how can you consume a get Api. Api in this post is made through ASP.Net C# which will be consumed by core PHP.

Data Model


Field
Description
ID
Row ID (Auto Increment)
NotesText
Text of notification
NotesType
Attachment Type (Text,Link,File)
Path
Location of Attachemntq
ClassID
Class Name
NewGIF
Description: http://ankuram.probuzzmedia.com/Image/Page/new.gif
CreateDate
Created Date


<table border="1" cellpadding="3" cellspacing="0">
                <tr>
                                <th>Sr No.</th>
                                <th>Notes Text</th>

                                <th>Notes Type</th>
                                <th>Path</th>
                                <th>Class</th>
                                <th>GIF</th>
                                <th>Date</th>
                </tr>

<?php

$url = 'http://ankuram.probuzzmedia.com/api/myapi/getnotification'; // path to your JSON file
$data = file_get_contents($url); // put the contents of the file into a variable
//$data = mb_substr($data, strpos($data, '{'));
//$data = mb_substr($data, 0, -1);
$result = json_decode($data,true);
$i=0;
foreach ($result as $key => $jsons)
{  
                foreach($jsons as $key => $value)
                {
         echo "<tr><td>".($i+1)."</td>";
                                 echo "<td>".$jsons[$i]['NotesText']."</td>";    
                                 echo "<td>".$jsons[$i]['NotesType']."</td>";
                                 echo "<td>".$jsons[$i]['Path']."</td>";         
                                 echo "<td>".$jsons[$i]['ClassID']."</td>";         
                                 echo "<td>".$jsons[$i]['NewGIF']."</td>";         
                                 echo "<td>".$jsons[$i]['CreateDate']."</td></tr>";         
                                 
                                 $i++;
    } 
               
}
?>
</table>


No comments:

Post a Comment