53
51

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iOSアプリのDL数を自動取得する方法

Last updated at Posted at 2014-09-19

アプリのダウンロード数を楽に取得したいと思って、下記のように自動取得してslackに通知するようにしました。

事前準備

AccessTokenの取得

売上のトレンド→レポートから取得します

スクリーンショット 2017-08-18 16.30.22.png

vendor_idの取得

AccessTokenを発行後、上記画面にTeam名+vendor_idが表示されるはずです。されない場合は更新などしてください。

ソースを準備した後に下記コマンドでも取得可能です。

java -jar Reporter.jar p=Reporter.properties Sales.getVendors

ソースの準備

下記取得用shellの例

IFS=$'\t'
# for mac
DATE=`date -v-2d +"%Y%m%d"`
# for centos
#DATE=`date --date '2 day ago' +%Y%m%d`
VENDOR_NO=
ORIGINAL_FILE="S_D_${VENDOR_NO}_${DATE}.txt"
NEW_FILE="S_D_${VENDOR_NO}_${DATE}.tsv"

# itunes storeからレポートファイル取得
java -jar Reporter.jar p=Reporter.properties Sales.getReport ${VENDOR_NO}, Sales, Summary, Daily, ${DATE}

# DLしたファイルをリネーム
gunzip ${ORIGINAL_FILE}.gz
mv ${ORIGINAL_FILE} ${NEW_FILE}

count=0
i=0

# TSVから各地域のDL数を合計
while read LINE; do
    # 1行目はタイトルなのでスキップ
    if [ "$i" -ne 0 ]
    then
        tsvList=(`echo "$LINE"`)
        let count=${count}+tsvList[7]
    fi
    let i=${i}+1
done < ${NEW_FILE}
rm ${NEW_FILE}

echo ${count}

# Slackに通知
payload='payload={"channel": "#channel-name", "username": "DL教えてbot", "text": "昨日のダウンロード者数は:'$count'", "icon_emoji": ":ghost:"}'
curlScript="curl -X POST --data '"$payload"' https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxxx"
eval ${curlScript}

アプリリースしたので、ぜひダウンロードお願いします!!

53
51
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
53
51

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?