Skip to content

Fix curlopt_postfields array to string conversion error #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@ protected static function getIncomingRequestHeaders($skippedHeaders = [])
return $results;
}

// https://gist.github.com/yisraeldov/ec29d520062575c204be7ab71d3ecd2f
protected static function build_post_fields( $data,$existingKeys='',&$returnArray=[]){
if(($data instanceof CURLFile) or !(is_array($data) or is_object($data))){
$returnArray[$existingKeys]=$data;
return $returnArray;
}
else{
foreach ($data as $key => $item) {
static::build_post_fields($item,$existingKeys?$existingKeys."[$key]":$key,$returnArray);
}
return $returnArray;
}
}


/**
* @param string $targetURL
* @return false|resource
Expand Down Expand Up @@ -324,7 +339,7 @@ protected static function createRequest($targetURL)
}
}

curl_setopt($request, CURLOPT_POSTFIELDS, $data + $_POST);
curl_setopt($request, CURLOPT_POSTFIELDS, static::build_post_fields($data + $_POST));
}

$headers = static::getIncomingRequestHeaders(static::getSkippedHeaders());
Expand Down