0

How do i call an api in php to save in mysql using cron jobs...??

i have an api and wanted to display it on my site, but i dont have experience about php and mysql. i know everything about html and css only. Now i want to save an api data in mysql using cron jobs in php script and after that i will show it on my site, help me plz

28th Nov 2016, 4:15 PM
Ajay Bamalwa
Ajay Bamalwa - avatar
5 Respuestas
+ 1
If you want to acces API via web, and get output of it. You can use cURL (Client URL) PHP. Set the require parameter(s) on API, and cURL will get the output from API. And then you only need insert its output to database.
28th Nov 2016, 5:00 PM
Fendi Septiawan
Fendi Septiawan - avatar
+ 1
You can learn cURL from this code on github, https://github.com/php-curl-class/php-curl-class Or, you can learn step by step from this website. http://www.techflirt.com/php/php-curl/index.html
28th Nov 2016, 5:30 PM
Fendi Septiawan
Fendi Septiawan - avatar
+ 1
First, you have to make a function for connecting to your db, mysql_connect('localhost', $username_db, $pass_db) Then you have to get output of cURL. Then you create sql query on your php, $query = 'INSERT bla.. bla... bla...' Finally, execute thats query using sql query function, mysql_query($query) Done...
28th Nov 2016, 5:48 PM
Fendi Septiawan
Fendi Septiawan - avatar
0
yes i want to access api url via web, but i dont know how to add parameters
28th Nov 2016, 5:19 PM
Ajay Bamalwa
Ajay Bamalwa - avatar
0
oky, did it. now i want to save this in mysql using cronjob. i have created cron job for my file. now how to save it in mysql...?? thanks for your help
28th Nov 2016, 5:38 PM
Ajay Bamalwa
Ajay Bamalwa - avatar