Skip to content

Instantly share code, notes, and snippets.

@Hootrix Hootrix/Xizi.php
Last active Aug 17, 2019

Embed
What would you like to do?
推送希子的最新微博到app通知
<?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
You can’t perform that action at this time.