API talk:Block

What's mean "Invalid IP address specified"? I specified some Open Proxy for block but give me this error. How can I fix it?Ladsgroup 01:37, 16 November 2011 (UTC)
 * It means the IP address isn't valid. It doesn't exist, can't edit your wiki, and can't be blocked. What IP address did you attempt to block? Reach Out to the Truth 03:28, 16 November 2011 (UTC)

The "block" option doesn't seem to be available in my wikimedia version. What version is required? The only available "action" commands I have are: login, logout, query, expandtemplates, parse, opensearch, feedwatchlist, help, paraminfo. Block is not one of them.

Hide
Is there an option to hide API blocks from the RC list (marking them as bot)? When done from the normal webpage the block is marked as bot edit. --Kevin 12:04, 21 August 2013 (UTC)

Can't block users with Internal API Call
Hello, I am trying to customize the UserMerge extension for our wiki's purposes by adding a block to the user that is being merged (if not deleted). To do so, I need to call the Block API internally. This is my code:

$params = new FauxRequest( array( 'action'=>'query', 'meta'=>'tokens', ));		$enableWrite = true; // This is set to false by default, in the ApiMain constructor $api = new ApiMain( $params, $enableWrite ); $api->execute; $data = & $api->getResult->getResultData; //Blocco l'utente //global $wgUser; //$token = $wgUser->getEditToken; $token = $data['query']['tokens']['csrftoken']; error_log($token);

$params = new FauxRequest( array( 'action'=>'block', 'user'=>$oldUser, 'token'=>$token, ), true); $enableWrite = true; // This is set to false by default, in the ApiMain constructor $api = new ApiMain( $params, $enableWrite ); $api->execute; //error_log( $data = & $api->getResult->getResultData );

Whether I use the first API call (that works), or $wgUser->getEditToken; I still get an Invalid Token when the second API is called (and its resulting Usage Exception). I also tried to rawurlencode or urlencode the token even if this is not done in the tutorials, same error. $oldUser is the username of the person being blocked and is correct.


 * I'm not familiar with the PHP side of things, but the two most common causes of a valid token being rejected are that you're not preserving and sending coookies, or that you're sending a GET request instead of a POST request. – Robin Hood  (talk)  18:53, 12 July 2016 (UTC)