sh Pocket.sh

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Pocket.sh相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env bash
# http://www.jamesfmackenzie.com/getting-started-with-the-pocket-developer-api/

export consumer_key="xxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export redirect_uri="http://localhost"

export coderesponse="request_token.json"
export tokenresponse="access_token.json"
export contentsresponse="pocket.json"

curl --silent https://getpocket.com/v3/oauth/request --insecure -X POST -H "Content-Type: application/json" -H "X-Accept: application/json" -d "{\"consumer_key\":\"$consumer_key\",\"redirect_uri\":\"$redirect_uri\"}" > $coderesponse # Get request token

code=$(cat $coderesponse | python -c 'import sys, json; print json.load(sys.stdin)["code"]') # Parse request_token.json and extract requst token.

echo "Request Token: " $code

url="https://getpocket.com/auth/authorize?request_token=$code&redirect_uri=$redirect_uri"

echo --------------------------------------------------------------------------------
echo $url
echo --------------------------------------------------------------------------------

read -n1 -r -p "Please visit this link and allow the application and PRESS a key to continue." key

curl --silent https://getpocket.com/v3/oauth/authorize --insecure -X POST -H "Content-Type: application/json" -H "X-Accept: application/json" -d "{\"consumer_key\":\"$consumer_key\",\"code\":\"$code\"}" >  $tokenresponse # Get Access token

access_token=$(cat $tokenresponse | python -c 'import sys, json; print json.load(sys.stdin)["access_token"]') # Parse access_token.json and extract access_token from it

echo "Access Token: " $access_token

# Authenticated Request to Retrieve Pocket Contents
curl --silent https://getpocket.com/v3/get --insecure -X POST -H "Content-Type: application/json" -H "X-Accept: application/json" -d "{\"consumer_key\":\"$\", \"access_token\":\"$access_token\"}" > $contentsresponse

cat  $contentsresponse  
echo
echo ------ FINISH ---
echo 

# cat  $contentsresponse  | python -m json.tool # Pretty print the result of authenticated request. 

以上是关于sh Pocket.sh的主要内容,如果未能解决你的问题,请参考以下文章

如何使我的命令行在具有扩展名(.sh)和名称如“weird.sh.sh.sh”的文件上工作

sh sh_template.sh

sh sh.sh

Linux下面如何运行 SH文件

配置告警系统主脚本main.sh mon.sh load.sh 502.sh disk.sh

shell 脚本各种执行方式(source ./*.sh, . ./*.sh, ./*.sh)的区别