Hello,
I want to use in my tool the new "Upload API".
I call (after login):
$new_file = <Name of the target file>;
$file = <URL of the source file>;
$desc = <Description>;
$this->server = 'commons.wikimedia.org'
$connect = fsockopen ($this->server, 80, $err_num, $err_str, 10);
$token = $this->get_token(); //Works
$message =
"filename=".urlencode($new_file)."&token=".urlencode($token)."&url=".$file."
&comment=".urlencode($desc);
if( $connect ) {
$query = "POST /w/api.php?format=php&action=upload HTTP/1.1
Host: ".$this->server."
Cookie: ".$cookies."
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7)
Gecko/20041107 Firefox/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: ".strlen($message)."
".$message."
\r\n\r\n";
fputs ($connect,$query);
The answer is: array(1) { ["upload"]=> array(1) {
["upload_session_key"]=>
int(<ID, e.g. 2095449403>) } }
But the file isn't uploaded. What do I wrong?
Viele Grüße
Jan