Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-14-2012, 07:31 PM
Vitti Vitti is offline
 
Join Date: Jan 2012
Location: CA
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vB API register_addmember Method Example

I am trying to add a new member using the API. Does anyone have an example on how to do so? I keep getting "Invalid API Signature" errors. I can get the signature to work correctly if I want to use the "member" method. But as soon as I use the "register_addmember" method and change it from GET to POST it throws an error.

I have looked at all the examples out there and have tried them and still can't get past the "Invalid API Signature". The docs don't show anything useful.

Any help would be greatly appreciated.

Thanks!
Reply With Quote
  #2  
Old 01-18-2013, 02:07 PM
gnasher gnasher is offline
 
Join Date: Jan 2013
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Vitti View Post
I am trying to add a new member using the API. Does anyone have an example on how to do so? I keep getting "Invalid API Signature" errors. I can get the signature to work correctly if I want to use the "member" method. But as soon as I use the "register_addmember" method and change it from GET to POST it throws an error.

I have looked at all the examples out there and have tried them and still can't get past the "Invalid API Signature". The docs don't show anything useful.

Any help would be greatly appreciated.

Thanks!
Hi Vitti,

I'm a new user of vBulletin, but I've managed to get this working today on v4.2, so I thought I'd share what I learnt just in case it helps you or someone in the future. The first thing I found on other posts is that there is an bug in api.php in that it only looks at variables sent by GET. Bit of a problem with methods that require POST, such as register_addmember. So make the following change to line 66 of api.php (or your equivalent).

Code:
// Remove this
//$VB_API_PARAMS_TO_VERIFY = $_GET;

// Add this
$VB_API_PARAMS_TO_VERIFY = $_REQUEST;
Secondly, to debug the issues I still had with "Invalid API Signature" errors I temporarily made a change to line 436 of /includes/init.php to pass back with the error message more information on what what combination of variables it was signing.

Code:
$signtoverify = md5(http_build_query($VB_API_PARAMS_TO_VERIFY, '', '&') . $VB_API_REQUESTS['api_s'] . $client['apiclientid'] . $client['secret'] . $vbulletin->options['apikey']);
$vbulletin->input->clean_array_gpc('r', array(
	'debug' => TYPE_BOOL,
));
if ($VB_API_REQUESTS['api_sig'] !== $signtoverify AND !($vbulletin->debug AND $vbulletin->GPC['debug']))
{
	//echo ' Should be: ' . $signtoverify . ' md5("' . http_build_query($VB_API_PARAMS_TO_VERIFY, '', '&') . $VB_API_REQUESTS['api_s'] . $client['apiclientid'] . $client['secret'] . '")';
	print_apierror('invalid_api_signature', 'Invalid API Signature'.http_build_query($VB_API_PARAMS_TO_VERIFY, '', '&'));
Other options for returning more information are to return the full string that is passed to the md5 function or if you want to check if your hash is the same as theirs then pass $signtoverify back as part of the error message.

They key things I learnt were...
  • The API version needs to be sent as api_version not api_v as suggested in the API Overview page https://www.vbulletin.com/forum/cont...7-API-Overview
  • The signed string needs to include api_version, which it isn't in the example in the API Overview.
  • Make sure the parameters to verify are in alphabetical order. The API Overview example does this with a ksort, but I overlooked this at first.
  • Make sure you URLEncode the variables if you're not using the php http_build_query function. I was using vb.net so made sure I passed each through Server.UrlEncode.
  • Make sure you're sending the signature as a 32 character hexadecimal string. This isn't the default for the md5 functions in vb.net. You're probably ok on that point if you got past the api_init

I hope that helps you or someone else. It was a bit painful learning how to use the API with minimal documentation available, but once you get the essentials understood it gets fairly easy.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09070 seconds
  • Memory Usage 2,178KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete