谷歌外链平台telegraのph发布脚本

挺有趣的一个站,当我在某告fourm看到有人分享这个平台可以免费发布外链,寻思就点击研究一下,不研究不知道。

竟然无需注册即可发布,不过手动发布很累,作为一个懂点SEO的站长,那肯定不能用手动模式去发。

这一site,看到果然有人在软件发,好像是老外:

随便点一个

那老外都这么干了,我们国人也不能干示弱了,经过我半天的不知道多久时间,终于搞定,本来还准备搞得精美点采集文章去发布在内嵌描文本,不过一想还要专门为此去找个网址来采集,还要担心内容量不够问题,what the fuck

那就直接搞简单点好了

搞几个测试关键词:

who is laomao
laomao 干啥的
laomaoseo 倒闭了吗
laomao的池子还在不在
laomao最近在搞什么鬼

创建个log目录用于记录下搞了多少外链

手动运行一下看看:

OK,就是这么简单粗暴

没有nofollow标签,可玩

代码:

<?php
$apiUrl = 'https://api.telegra.ph/';  
function Removeusedkey($keywordFile) {  
    $keywords = file($keywordFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);  
    if (empty($keywords)) {  
        throw new Exception("$keywordFile中没有关键词");  
    }
    $randomIndex = array_rand($keywords);  
    $randomKeyword = $keywords[$randomIndex];  
    unset($keywords[$randomIndex]);  
    file_put_contents($keywordFile, implode(PHP_EOL, $keywords));  
      
    return $randomKeyword;  
}  
function Getrankey($length) {  
    $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';  
    $charactersLength = strlen($characters);  
    $randomString = '';  
    for ($i = 0; $i < $length; $i++) {  
        $randomString .= $characters[rand(0, $charactersLength - 1)];  
    }  
    return $randomString;  
}  
try {  
    $keywordFile = 'keyword.txt';  
    $randomKeyword = Removeusedkey($keywordFile);  
    $title = Getrankey(rand(12, 30));  
    $contentBase = Getrankey(rand(500, 1000));  
    $contentNodes = [  
    [  
        'tag' => 'p',  
        'children' => [  
            [
                'tag' => null,
                'children' => [$contentBase]  
            ],  
            [
                'tag' => 'a',  
                'attrs' => ['href' => 'https://www.laomaoseo.vip/'],  
                'children' => [  
                    [
                        'tag' => 'b',  
                        'children' => [$randomKeyword]  
                    ]  
                ]  
            ],  
        ]  
    ]  
]; 
$createAccountParams = [  
    'short_name' => 'AutoCreated' . uniqid(),
    'author_name' => 'Laomaoseo',  
    'author_url' => 'https://www.laomaoseo.vip/'  
];  
$createPageParams = [  
    'title' => $title,  
    'author_name' => 'Laomaoseo',  
    'author_url' => 'https://www.laomaoseo.vip/',  
    'content' => json_encode($contentNodes),
    'return_content' => false
];  
$ch = curl_init($apiUrl . 'createAccount');  
curl_setopt($ch, CURLOPT_POST, true);  
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($createAccountParams));  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
$accountResponse = curl_exec($ch);  
curl_close($ch);  
$accountData = json_decode($accountResponse, true);  
if ($accountData['ok'] && isset($accountData['result']['access_token'])) {  
    $accessToken = $accountData['result']['access_token'];  
    $createPageParams['access_token'] = $accessToken;  
    $ch = curl_init($apiUrl . 'createPage');  
    curl_setopt($ch, CURLOPT_POST, true);  
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($createPageParams));  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
    $pageResponse = curl_exec($ch);  
    curl_close($ch);  
    $pageData = json_decode($pageResponse, true);  
    if ($pageData['ok'] && isset($pageData['result']['url'])) {  
        echo "发布成功,网址:" . $pageData['result']['url'];  
    } else {  
        echo "发布失败:" . ($pageData['error'] ?? '未知错误');  
    }  
} else {  
    echo "账户创建失败:" . ($accountData['error'] ?? '未知错误');  
}  
if ($pageData['ok'] && isset($pageData['result']['url'])) {  
    $logDir = 'log';  
    if (!is_dir($logDir)) {  
        mkdir($logDir, 0755, true);  
    }  
      
    $date = date('Ymd');
    $logFile = "{$logDir}/{$date}.txt";  
      
    file_put_contents($logFile, $pageData['result']['url'] . PHP_EOL, FILE_APPEND | LOCK_EX);
    } 
      
} catch (Exception $e) {  
    echo $e->getMessage();  
}
?>
属于什么分类:

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注