Last active
August 17, 2019 08:45
-
-
Save Hootrix/32baa4e608b9f7558fb13ed7ef21112b to your computer and use it in GitHub Desktop.
推送希子的最新微博到app通知
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: pang | |
* Date: 2019/3/22 0022 | |
* Time: 1:11 | |
* | |
* 使用Bark App的推送url操作 | |
* | |
* | |
* 推送 标题: | |
* 前缀 - 时间 - 微博内容 | |
* | |
* | |
* 指定微博用户id:uid | |
* 请求:?uid=1613133581 | |
*/ | |
date_default_timezone_set('Asia/Shanghai'); | |
if (isset($_GET['uid'])) { | |
$appid = '';//Bark App id | |
$pre = '小阔爱希希'; | |
//微博widget接口 已经失效 | |
// $content = file_get_contents("http://service.weibo.com/widget/widget_blog.php?uid={$_GET['uid']}&height=1700&skin=wd_01&showpic=1"); | |
// preg_match_all('/<p class="wgtCell_txt">(?<text>.*?)<\/p>.*?<span[^>]+class="wgtCell_tm"><a[^>]+href="(?<url>https?:\/\/weibo.com\/[a-zA-Z0-9]{3,}\/(?<mblogid>\w+))"[^>]+>(?<time>[^<]+)<\/a><\/span>/si', $content, $_); | |
//使用三方微博rss数据 2019-08-17修改 | |
$content = file_get_contents("https://api.izgq.net/weibo/rss/{$_GET['uid']}"); | |
$xmlDoc = simplexml_load_string($content); | |
$title = trim((string)$xmlDoc->channel->item[0]->title); | |
$link = trim((string)$xmlDoc->channel->item[0]->link); | |
$_mblogid = explode('/',$link); | |
$mblogid = end($_mblogid); | |
$pubDate = trim((string)$xmlDoc->channel->item[0]->pubDate); | |
$pubDate = date("Y-m-d H:i:s",strtotime($pubDate)); | |
//准备消息内容 | |
$url = sprintf('https://api.day.app/' . $appid . '/%s?url=sinaweibo://detail?mblogid=%s', urlencode(sprintf('%s - %s - %s', $pre, $pubDate, $title)), $mblogid); | |
file_get_contents($url) || die('request error'); | |
echo 'success'; | |
return; | |
} | |
echo 'error'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment