Это должно дать вам некоторое представление:
<?php
//connect to your database
mysql_connect("localhost", "username", "password");
mysql_select_db("somedb");
//read your text file into an array, one entry per line
$lines = file('filename.txt');
//loop through each website URL you read from the file
foreach ($lines as $website_url) {
//make the request to the compete API
$response = file_get_contents("http://apps.compete.com/sites/" . $website_url . "/trended/rank/?apikey=0sdf456sdf12sdf1");
//the error I saw was in JSON, so decode the request
$response = json_decode($request);
//get the rank from the response, I don't know what a real response looks like
$rank = $response['something'];
//insert the website URL and its rank into your table
mysql_query("INSERT INTO website_ranks (website_url, rank) VALUES ('" . mysql_real_escape_string($website_Url) . "', " . $rank . ")");
}
?>
У меня недостаточно деталей, чтобы написать рабочий код.