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
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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.