Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/Telnyx.php: $apiBase is set to localhost #91

Open
aetikon opened this issue Oct 16, 2024 · 2 comments
Open

lib/Telnyx.php: $apiBase is set to localhost #91

aetikon opened this issue Oct 16, 2024 · 2 comments

Comments

@aetikon
Copy link

aetikon commented Oct 16, 2024

Just upgraded to 3.0.0 and the API calls broke because it's trying to connect to localhost:

Telnyx\Exception\ApiConnectionException Could not connect to Telnyx (http://localhost:12111/v2/number_lookup/1719490XXXX). Please check your internet connection and try again. If this problem persists, you should check Telnyx's service status at http://status.telnyx.com/, or let us know at [email protected].

The solution is to edit lib/Telnyx.php and uncomment $apiBase to set the correct endpoint:

    public static $apiBase = 'https://api.telnyx.com';
    //public static $apiBase = 'http://localhost:12111';
@weroh
Copy link
Contributor

weroh commented Oct 16, 2024

Whoever is updating this plugin should know that I built this library so that you can override the apiBase outside of Telnyx.php just to prevent this issue from accidentally happening. There were sample docs that had this code some time ago and were probably lost.

Example script which overrides apiBase in index.php:

<?php
namespace Telnyx;
require_once(dirname(__FILE__) . '/telnyx-php/vendor/autoload.php');

Telnyx::setApiKey(MY_API_KEY);
Telnyx::$apiBase = 'http://localhost:12111';

$response = \Telnyx\NumberLookup::all();
var_dump($response);

@sgtcoder
Copy link

Why was it changed from https://api.telnyx.com to localhost?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants