トークンはtwitterの開発者登録して取得してください
このプログラムのrepeat~loop間で数分から数十分待つと落ちます
#include "hspinet.as"
#include "encode.as"
#include "hsp3util.as"
;
; サーバー上のファイル情報を得る
;
screen 0,1300,120
title "速報"
*nn
color 0,0,255
boxf
count = 0
netinit
if stat : dialog "ネット接続できません。" : end
netheader "Authorization: Bearer //ここにトークン"
neturl "https://api.twitter.com/1.1/search/"
repeat
netrequest_get "tweets.json?q=from%3Anhk_news+%E3%80%90%E9%80%9F%E5%A0%B1+JUST+IN+%E3%80%91&lang=ja&locale=ja&result_type=recent&count=1"
repeat
netexec res
if res : break
await 100
loop
netgetv json
jsonopen json,json
jsongetobj json,"statuses",json
jsonnext json,json,2
jsongetobj json,"text",json
jsonout out,json
out = utf8n2sjis(out)
out = strmid(out,18,instr(out,0,"#nhk_news")-18)
outin = instr(out,20," ")
out01 = strmid(out,0,20+outin)
out02 = strmid(out,20+outin,strlen(out)-20-outin)
if outin = -1 {
out=out01
out02=""
}
if out = "" {
await 900000
goto *nn
}
if out = out1 {
} else {
goto *new
}
out = out1
await 5000
loop
stop
*new
gosub *op
color 255,255,255 : textmode 2,2
color 0,0,0 : pos 15,0
text 70
emes out01
pos 0,
emes out02
await 5000
color 0,255,0 : boxf
color 0,0,0 : pos 342,0
mes "ニュース速報/終",5
await 1000
color 0,255,0 : boxf
await 2000
if count = 0 {
count++
goto *new
} else {
goto *nn
}
*op
out1 = out
color 0,255,0
boxf
pos 372
color 0,0,0
font "ヒラギノ角ゴシック W6",40,16,3
objcolor 255,255,255
mes "ニュース速報",5
await 100
color 0,255,0
boxf
await 500
pos 372
color 0,0,0
mes "ニュース速報",5
await 500
color 0,255,0
boxf
await 500
pos 372
color 0,0,0
mes "ニュース速報",5
await 500
color 0,255,0
boxf
await 1000
return