Jump to content

Trouble with basic api call


Recommended Posts

I'm attempting to make a basic call to the api using the example code found in the documentation, and I'm not seeing anything resulting in the php echo. Can someone point me in the right direction? I have a basic grasp of php. I also am sure that the api key has access to api/core/hello as set in the AdminCP.

 

<?php
      $communityUrl = 'https://www.poolspaforum.com/forum/';
      $apiKey = 'myapikey';

      $curl = curl_init( $communityUrl . 'api/core/hello' );
      curl_setopt_array( $curl, array(
          CURLOPT_RETURNTRANSFER	=> TRUE,
          CURLOPT_HTTPAUTH	=> CURLAUTH_BASIC,
          CURLOPT_USERPWD		=> "{$apiKey}:"
      ) );
      $response = curl_exec( $curl );

      echo $response;
?>
<h1>Hi</h1>

 

Link to comment
Share on other sites

  • 3 weeks later...

Thank you for the response. I'm receiving no curl errors with the below.
 

<?php
    $communityUrl = 'http://poolspaforum.com/forum/api';
    $apiKey = 'mtapikey';

    $curl = curl_init( $communityUrl . '/core/members' );
    curl_setopt_array( $curl, array(
        CURLOPT_RETURNTRANSFER	=> TRUE,
        CURLOPT_HTTPAUTH	=> CURLAUTH_BASIC,
        CURLOPT_USERPWD		=> "{$apiKey}:"
    ));

	if(curl_exec($curl) === false){
    	echo 'Curl error: ' . curl_error($curl);
	}else{
    	echo 'Operation completed without any errors';
	}

    $response = curl_exec( $curl );

?>
<h1>Hi</h1>

<p><?php echo $response; ?></p>

 

Link to comment
Share on other sites

I'm receiving the following in my response. My community url is correct, is that not the right path for /core/members?

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

Link to comment
Share on other sites

26 minutes ago, dwood@bigfishpublications.com said:

I'm receiving the following in my response. My community url is correct, is that not the right path for /core/members?

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

Are you sure your path is correct? Your sample code above is pointing to:

http://poolspaforum.com/forum/api/core/members

You probably intend to land at poolspaforum.com/api/core/members assuming IPB is installed at the root of the domain. Also, do you intent to use https?

You should see results once you have the correct address in your browser with something like this example using IPB's site:

http://invisioncommunity.com/api/core/hello

Link to comment
Share on other sites

  • Recently Browsing   0 members

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