From 14a6a27213515b5d6790508281fb0ece6daa3145 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Jun 2014 21:52:49 -0700 Subject: limited progress in providing a POST option to shredder, back to auth signature mismatches again, likely a quoting issue --- util/shredder/ShredOAuth.sh | 27 +++++++++++++++++++-------- util/shredder/shredder | 41 +++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/util/shredder/ShredOAuth.sh b/util/shredder/ShredOAuth.sh index 9e808a2d6..9828124c7 100755 --- a/util/shredder/ShredOAuth.sh +++ b/util/shredder/ShredOAuth.sh @@ -174,13 +174,16 @@ FO_statuses_home_timeline () { FO_command () { local command="$1" - local opts="$2" + local post="$2" + declare -a opts=("${!3}") local params=( $(OAuth_param 'screen_name' $screen_name) $(OAuth_param 'count' $count) ) -#echo ${opts[@]} +#echo "$3" +#echo '---' +#echo "${opts[@]}" convscreen=$(OAuth_PE "$screen_name"); data="screen_name=${convscreen}&count=${count}" @@ -189,19 +192,27 @@ FO_command () { for b in ${opts[@]}; do lhs=`echo $b | awk -F= '{print $1};'` rhs=`echo $b | awk -F= '{print $2};'` - params=("${params[@]}" $(OAuth_param $lhs $rhs)) - data=$data"&"$lhs=$rhs + params=("${params[@]}" $(OAuth_param "$lhs" "$rhs")) + data=$data"&""$lhs"="$rhs" done fi -#echo ${params[@]} +#echo 'params: ' ${params[@]} -#echo $data +#echo 'data: ' $data + local auth_header=''; - local auth_header=$(OAuth_authorization_header 'Authorization' "$redmatrix_url" '' '' 'GET' "${redmatrix_url}/api/${command}.json" ${params[@]}) + if [ "$post" == '1' ]; then + auth_header=$(OAuth_authorization_header 'Authorization' "$redmatrix_url" '' '' 'POST' "${redmatrix_url}/api/${command}.json" ${params[@]}) + FO_ret=$(curl -s "${redmatrix_url}/api/${command}.json" --data-urlencode "${data}" --header "${auth_header}") + + else + auth_header=$(OAuth_authorization_header 'Authorization' "$redmatrix_url" '' '' 'GET' "${redmatrix_url}/api/${command}.json" ${params[@]}) + FO_ret=$(curl -s --get "${redmatrix_url}/api/${command}.json" --data "${data}" --header "${auth_header}") + + fi - FO_ret=$(curl -s --get "${redmatrix_url}/api/${command}.json" --data "${data}" --header "${auth_header}") FO_rval=$? return $FO_rval diff --git a/util/shredder/shredder b/util/shredder/shredder index 5073d5b2f..1586746e0 100755 --- a/util/shredder/shredder +++ b/util/shredder/shredder @@ -155,10 +155,10 @@ main () { fcli_in_reply_to_status_id= fcli_file= fcli_help_flag= - JS_Fields=() fcli_opts= + fcli_post= - while getopts "C:c:s:r:f:q:h" name + while getopts "C:c:s:r:f:q:hp" name do case $name in c) fcli_command="$OPTARG";; @@ -167,6 +167,7 @@ main () { r) fcli_in_reply_to_status_id="$OPTARG";; f) fcli_file="$OPTARG";; h) fcli_help_flag="1";; + p) fcli_post="1";; q) fcli_opts=("${fcli_opts[@]}" "$OPTARG");; ?) usage exit 2;; @@ -175,9 +176,9 @@ main () { load_config if [[ "$fcli_help_flag" == "1" ]]; then case $fcli_command in - statuses_update) - show_statuses_update 0 - ;; +# statuses_update) +# show_statuses_update 0 +# ;; home_timeline) show_home_timeline 0 ;; @@ -202,20 +203,24 @@ main () { return $FO_rval ;; - statuses_update) - [[ "$fcli_status" == "" ]] && show_statuses_update 1 - FO_statuses_update 'json' "$fcli_status" "$fcli_in_reply_to_status_id" - JS_Parsed=$(echo "$FO_ret" | tokenize | parse) - echo "$JS_Parsed" | js "user" "name" , - echo -n " - " - echo "$JS_Parsed" | js "created_at" - echo "$JS_Parsed" | js "text" - echo "" - echo "------------------------------------------------------------------------------" - return $FO_rval - ;; +# statuses_update) +# [[ "$fcli_status" == "" ]] && show_statuses_update 1 +# FO_statuses_update 'json' "$fcli_status" "$fcli_in_reply_to_status_id" +# JS_Parsed=$(echo "$FO_ret" | tokenize | parse) +# echo "$JS_Parsed" | js "user" "name" , +# echo -n " - " +# echo "$JS_Parsed" | js "created_at" +# echo "$JS_Parsed" | js "text" +# echo "" +# echo "------------------------------------------------------------------------------" +# return $FO_rval +# ;; + *) - FO_command $fcli_command ${fcli_opts[@]} + +# echo "${fcli_opts[@]}" + + FO_command "$fcli_command" "$fcli_post" fcli_opts[@] echo $FO_ret -- cgit v1.2.3