学习了一下接口
顺带写了一个简单的
<?php
//存有美图链接的文件名img.txt
$filename = "img.txt";
if(!file_exists($filename)){
die('文件不存在');
}
//从文本获取链接
$pics = [];
$fs = fopen($filename, "r");
while(!feof($fs)){
$line=trim(fgets($fs));
if($line!=''){
array_push($pics, $line);
}
}
//从数组随机获取链接
$pic = $pics[array_rand($pics)];
//返回指定格式
$type=$_GET['type'];
switch($type){
//JSON返回
case 'json':
header('Content-type:text/json');
die(json_encode(['pic'=>$pic]));
default:
die(header("Location: $pic"));
}
?>
#include<stdio.h>
int main(void)
{
FILE *fp;
char *ch;
fp = fopen("img.txt","a+");
for(int i=0;i<=6306;i++)
fprintf(fp,"图片所在位置/%d.jpg\n",i);
fclose(fp);
return 0;
}
用c生成img.txt
然后php调用读取
扔在一起
结束
叨叨几句... NOTHING