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

Request: New Map feature to be added #30

Closed
vekien opened this issue Apr 20, 2021 · 5 comments · Fixed by #33
Closed

Request: New Map feature to be added #30

vekien opened this issue Apr 20, 2021 · 5 comments · Fixed by #33

Comments

@vekien
Copy link

vekien commented Apr 20, 2021

Hello!

I really love IP info and recently you guys launched: Map IPs: https://ipinfo.io/map

Would it be possible to get this in the library? I was thinking of PRing it but unsure if it's more of an "experimental/fun" thing at the moment or if it's something that will stick around and is production ready.

Kind Regards!

@UmanShahzad
Copy link
Contributor

Hey @viion , really glad you like the new feature!

From my side, I don't see much value of putting this into the PHP SDK (or any SDK). The output is only going to be some JSON with a link like this:

$ cat ips.txt | curl -XPOST --data-binary @- "ipinfo.io/map?cli=1"
{
  "status": "Report Generated",
  "reportUrl": "https://ipinfo.io/map/7e55cd2d-a6d9-4724-bb6e-e0c8ac7daf6e"
}

If the intention is to input IPs to an SDK function and then use that link to be displayed somewhere in your app, then that would make sense. But I can't see any other use case. What do you think?

@coderholic any idea if this is worth putting into SDKs?

@vekien
Copy link
Author

vekien commented Apr 21, 2021

I wonder if it would just be for convenience, I guess it would need to align with the goals of this functionality.

An example use case I have: At my company we monitor AWS ALB logs, and we have reports generated daily about where traffic came from and this uses ipinfo php library to get region/city etc, and we build dashboards on that.

With the introduction of maps I have now added this to our report generation script:

$ipfilename = self::SAVE_PATH .'/ip_list';
file_put_contents($ipfilename, implode("\n", $ips));

// generate map from ipinfo
$response = shell_exec('cat '. $ipfilename .' | curl -XPOST --data-binary @- "ipinfo.io/map?cli=1"');
$response = json_decode(trim($response), true);
$entity->setMapLink($response['reportUrl']);

So I'm basically just doing a shell_exec to run the example your page says, which works perfectly it's all fine and dandy, at the time I just thought "be handy if I could do $ipinfo->generateMapLink($ips) 😊" - This report sends a message on Slack that now includes a link directly to the map. So it's all automated, as our management/higher up love this map lol

Just thought i'd bring up to discuss, as ipinfo is so simple and convenient to use anyway!

@UmanShahzad
Copy link
Contributor

I love that use case, thanks for sharing!

Will get back to you fairly soon about this; hoping we can add it :)

@UmanShahzad
Copy link
Contributor

Alright got the 👍 to implement this; will do it soon.

@UmanShahzad
Copy link
Contributor

Available in v2.2.0.

Example from test cases:

$h = new IPinfo();
$url = $h->getMapUrl(file("tests/map-ips.txt"));
echo "got URL ".$url;

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

Successfully merging a pull request may close this issue.

2 participants