Jump to content

Using a different local IP to run API's


stijnvb

Recommended Posts

I would like to use an external API, and access it with my 2nd IP address of the server.

 

Is this possible? And if so, how?

 

Example:

primary ip: 4.5.6.7

secondary ip: 4.5.6.8

 

primary ip is used to host several websites

the PHP script I made runs in CLI, I want it to access the external API from my secondary ip.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/227489-using-a-different-local-ip-to-run-apis/
Share on other sites

Hi stijnvb,

I've never done this myself but I think you can achieve what you are looking for by utilising PHP's socket functons. Have a look in the manual at "Socket" and "fsockopen()" in particular.

Cheers,

Fergal

 

Thanks for the tip.

I'm not sure why I didn't think of it sooner, but I just used cURL, as I stated in an earlier post ...

i was using a class provided by the API provider, and did not really bother looking into it.

 

Problem solved :-) Thanks for the help!

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.