0

Do any of you know a way to get datas from a database of a website? I already studied and made a program that POST data using json. It gets the shipment status of a certain tracking number and if it's shipped, it will be changed to delivered. And I already done that.

Now what I'm trying to do is get all the datas, or the row of that tracking number and then encode it to JSON. But I don't know what to do.

This is how I did the first program: on getting a specific tracking number and update the status to delivered.

<?php

$url='https://sample.com.ph';
$apikey='apikey';
$method ='SendPackageStatus';


    $data = array(
        'package'   => array(
             'tracking_number'  =>  '735898532',
             'package_status'    => 'delivered',
             'failed_reason'     => '',
             'updated_at'        => '2014-01-01 07:02:14'
         )
     );
     $check=json_encode($data);

     $postdata = "&data=$check&apikey=$apikey&method=$method";
     $ch = curl_init();

    curl_setopt_array(
        $ch,
        array(

            CURLOPT_URL => $url.'/webservice/',
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_FOLLOWLOCATION  => true,
            CURLOPT_VERBOSE         => true,
            CURLOPT_POST => 1,
        CURLOPT_POSTFIELDS      => $postdata,
        CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_HTTPHEADER => array('Content-type:  application/x-www-form-urlencoded', 

            )
        )
    );


     $result = curl_exec($ch);
     curl_close($ch);
     echo $result;



?>

1 Answer 1

1

Why not use mysql?... you can store json string on db (as..strings). I dont follow what you are trying to do.

Sign up to request clarification or add additional context in comments.

4 Comments

I'm building an adapter. And what I would try to do is to connect the database of a website to the program, get the rows I needed and then pass it to another website's database. I tried POSTing first and I did it. Now I need to get the rows that I needed.
you can connect to a remote database. thats not a problem. php.net/mysql_connect
then, I can connect to the database of that website? will I need passwords or something?
of course.. database is confidential.. if you dont have its credentials, you wont be able to watch, add or change data inside of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.