diff options
Diffstat (limited to 'util/shredder/ShredOAuth.sh')
-rwxr-xr-x | util/shredder/ShredOAuth.sh | 27 |
1 files changed, 19 insertions, 8 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 |