xDEADC0DE Posted August 2, 2018 Share Posted August 2, 2018 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 More sharing options...
newbie LAC Posted August 2, 2018 Share Posted August 2, 2018 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 More sharing options...
xDEADC0DE Posted August 2, 2018 Author Share Posted August 2, 2018 omg i totally missed that! thank you <3 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.