Jump to content

Fetch memberinfo via /core/members REST api


xDEADC0DE

Recommended Posts

Hi there invision community,

i've just setup my rest api and the core/hello example request works as expected. Now im trying to fetch some variables via the members username but i dont get it to work. Can please someone tell me how to do this correctly?  At the moment the api returns: string(66) "{ "errorCode": "1C292\/9", "errorMessage": "NO_PASSWORD" }"

Response Code in API Logs is: 403 Forbidden

 

<?php
	$communityUrl = 'https://mywebsite.com/';
	$apiKey = 'xxx';
		
	$curl = curl_init( $communityUrl . 'api/core/members' );
	curl_setopt_array( $curl, array(
		CURLOPT_RETURNTRANSFER	=> TRUE,
		CURLOPT_HTTPAUTH		=> CURLAUTH_BASIC,
		CURLOPT_USERPWD			=> "{$apiKey}:",
		CURLOPT_POST			=> true,
        CURLOPT_POSTFIELDS		=> "name=myusername"
	) );
	$response = curl_exec( $curl );

	var_dump($response);

 

Thanks in advance!

Link to comment
Share on other sites

Hello,

https://invisioncommunity.com/developers/rest-api?endpoint=core/members/GETindex

You should send GET instead of POST

<?php
	$communityUrl = 'https://mywebsite.com/';
	$apiKey = 'xxx';
		
	$curl = curl_init( $communityUrl . 'api/core/members/?name=myusername' );
	curl_setopt_array( $curl, array(
		CURLOPT_RETURNTRANSFER	=> TRUE,
		CURLOPT_HTTPAUTH		=> CURLAUTH_BASIC,
		CURLOPT_USERPWD			=> "{$apiKey}:",
	) );
	$response = curl_exec( $curl );

	var_dump($response);

This will return members which names contain myusername value like

myusername1

itsmyusername

myusernamefoo

barmyusername

etc

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...