0

I am trying to call webservice APi and display the result of that in our web page. i am trying below code, but its not fetching the status :

    <table class="tbl-qa" border="1">
          <thead>
            <tr>            
              <th class="table-header">ID</th>
              <th class="table-header">ORDERID</th>            
              <th class="table-header">Status</th>           
            </tr>
          </thead>
          <tbody id="table-body">



          <?php
$tabindex = 1;

if (!empty($orderrecords))
    {
    foreach($orderrecords as $k => $v)
        {
?>

                <?php
        $hide = '';
        $data['username'] = '';
        $data['password'] = '';
        $data['awb'] = '890927143';
        $url = 'https://plapi.ecomexpress.in/track_me/api/mawbd/?awb=awbnumber&order=' . $orderrecords[$k]["order_id"] . '&username=admin&password=admin123';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $output = curl_exec($ch);
        curl_close($ch);
        $res = explode("\n", $output);
        if (!isset($res[13]))
            {
            $res[13] = null;
            }

        $status = $res[13];
?>         

              <tr value="" <?php
        echo $hide; ?> class="table-row" id="table-row-<?php
        echo $orderrecords[$k]["id"]; ?>" tabindex="<?php
        echo $tabindex; ?>">

              <td><input type="checkbox" onclick="assignorderids('<?php
        echo $orderrecords[$k]["order_id"]; ?>')" name="assigneeid" id="assigneeid-<?php
        echo $orderrecords[$k]["order_id"]; ?>" value="<?php
        echo $orderrecords[$k]["order_id"]; ?>"></td>

                <td>

                <?php
        echo $orderrecords[$k]["order_id"]; ?>

                </td>

             <td><?php
        echo $status; ?></td>

              </tr>
            <?php
        $tabindex++;
        }
    } ?>
          </tbody>
        </table>

Please let me know if you need more information. I am using php mysqli....

I am trying in localhost.... is i need to try in server to make it work?

1 Answers1

0

With the data you provided, the SSL certificate seems to not be valid. Maybe try setting this in your cUrl

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
u_mulder
  • 54,101
  • 5
  • 48
  • 64
chaensel
  • 183
  • 3
  • 15
  • careful though. this deactivated SSL thus making your script unsecure. Its better to import a certificate on your local machine. See also here: https://stackoverflow.com/questions/9774349/php-curl-not-working-with-https – Erik Kalkoken Feb 22 '18 at 11:40