limited progress in providing a POST option to shredder, back to auth signature mismatches again, likely a quoting issue

This commit is contained in:
friendica 2014-06-19 21:52:49 -07:00
parent 525daa7475
commit 14a6a27213
2 changed files with 42 additions and 26 deletions

View File

@ -174,13 +174,16 @@ FO_statuses_home_timeline () {
FO_command () { FO_command () {
local command="$1" local command="$1"
local opts="$2" local post="$2"
declare -a opts=("${!3}")
local params=( local params=(
$(OAuth_param 'screen_name' $screen_name) $(OAuth_param 'screen_name' $screen_name)
$(OAuth_param 'count' $count) $(OAuth_param 'count' $count)
) )
#echo ${opts[@]} #echo "$3"
#echo '---'
#echo "${opts[@]}"
convscreen=$(OAuth_PE "$screen_name"); convscreen=$(OAuth_PE "$screen_name");
data="screen_name=${convscreen}&count=${count}" data="screen_name=${convscreen}&count=${count}"
@ -189,19 +192,27 @@ FO_command () {
for b in ${opts[@]}; do for b in ${opts[@]}; do
lhs=`echo $b | awk -F= '{print $1};'` lhs=`echo $b | awk -F= '{print $1};'`
rhs=`echo $b | awk -F= '{print $2};'` rhs=`echo $b | awk -F= '{print $2};'`
params=("${params[@]}" $(OAuth_param $lhs $rhs)) params=("${params[@]}" $(OAuth_param "$lhs" "$rhs"))
data=$data"&"$lhs=$rhs data=$data"&""$lhs"="$rhs"
done done
fi 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=$? FO_rval=$?
return $FO_rval return $FO_rval

View File

@ -155,10 +155,10 @@ main () {
fcli_in_reply_to_status_id= fcli_in_reply_to_status_id=
fcli_file= fcli_file=
fcli_help_flag= fcli_help_flag=
JS_Fields=()
fcli_opts= 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 do
case $name in case $name in
c) fcli_command="$OPTARG";; c) fcli_command="$OPTARG";;
@ -167,6 +167,7 @@ main () {
r) fcli_in_reply_to_status_id="$OPTARG";; r) fcli_in_reply_to_status_id="$OPTARG";;
f) fcli_file="$OPTARG";; f) fcli_file="$OPTARG";;
h) fcli_help_flag="1";; h) fcli_help_flag="1";;
p) fcli_post="1";;
q) fcli_opts=("${fcli_opts[@]}" "$OPTARG");; q) fcli_opts=("${fcli_opts[@]}" "$OPTARG");;
?) usage ?) usage
exit 2;; exit 2;;
@ -175,9 +176,9 @@ main () {
load_config load_config
if [[ "$fcli_help_flag" == "1" ]]; then case $fcli_command in if [[ "$fcli_help_flag" == "1" ]]; then case $fcli_command in
statuses_update) # statuses_update)
show_statuses_update 0 # show_statuses_update 0
;; # ;;
home_timeline) home_timeline)
show_home_timeline 0 show_home_timeline 0
;; ;;
@ -202,20 +203,24 @@ main () {
return $FO_rval return $FO_rval
;; ;;
statuses_update) # statuses_update)
[[ "$fcli_status" == "" ]] && show_statuses_update 1 # [[ "$fcli_status" == "" ]] && show_statuses_update 1
FO_statuses_update 'json' "$fcli_status" "$fcli_in_reply_to_status_id" # FO_statuses_update 'json' "$fcli_status" "$fcli_in_reply_to_status_id"
JS_Parsed=$(echo "$FO_ret" | tokenize | parse) # JS_Parsed=$(echo "$FO_ret" | tokenize | parse)
echo "$JS_Parsed" | js "user" "name" , # echo "$JS_Parsed" | js "user" "name" ,
echo -n " - " # echo -n " - "
echo "$JS_Parsed" | js "created_at" # echo "$JS_Parsed" | js "created_at"
echo "$JS_Parsed" | js "text" # echo "$JS_Parsed" | js "text"
echo "" # echo ""
echo "------------------------------------------------------------------------------" # echo "------------------------------------------------------------------------------"
return $FO_rval # return $FO_rval
;; # ;;
*) *)
FO_command $fcli_command ${fcli_opts[@]}
# echo "${fcli_opts[@]}"
FO_command "$fcli_command" "$fcli_post" fcli_opts[@]
echo $FO_ret echo $FO_ret