API: How to login and execute Commands?

  • 1
  • Question
  • Updated 5 years ago
Hello,

where can i find a documentation for this kind of API(for absolute beginners please)

The best would be a 5min video tutorial, that explains it in 1,2,3 steps.

Without knowing the syntax it is impossible to login or execute commands.

thank you
Photo of bnewsblur

bnewsblur

  • 6 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of Josh Sled

Josh Sled

  • 123 Posts
  • 36 Reply Likes
This isn't exactly what you're asking for, but the following is a script I use to backup my newsblur data locally; it uses the command-line program "curl" to execute a sequence of operations against the API. Perhaps looking at it will set you on the right track:


#!/bin/bash

if [ "x$1" = "x" -o "x$2" = "x" ]; then
echo "${0} [password] [starred item page count]";
exit 1;
fi

cookieJar=/tmp/nb-cookies

# login to establish an authentication cookie
login_output=$(curl --cookie-jar ${cookieJar} -d username=jsled -d password="$1" http://www.newsblur.com/api/login)
# parse my user_id from the json response
user_id=$(echo $login_output | jq '.user_id')
echo "parsed user_id [${user_id}]"

# export subscriptions as OPML
curl --cookie ${cookieJar} http://www.newsblur.com/import/opml_export -o newsblur-subscriptions.opml

# save all the pages of starred items.
for i in $(seq $2); do
curl --cookie ${cookieJar} http://www.newsblur.com/reader/starred_stories"?page=${i}" -o starred-page-$(printf "%0.2d" ${i}).json;
done

# export my shared stories
curl --cookie ${cookieJar} http://www.newsblur.com/social/stories/${user_id}/jsled -o shared-stories.json

# cleanup
#rm ${cookieJar}