MAHDLab / rIP

Detecting Fraud in Online Surveys by Tracing, Scoring, and Visualizing IP Addresses
MIT License
26 stars 4 forks source link

Does the function getIPinfo only works with numeric vectors? #1

Closed jpospina88 closed 5 years ago

jpospina88 commented 5 years ago

Hi,

I have a dataset exported from Qualtrics with IPs that I'd like to check but when I call the column of the IP Addresses and add my API Key from iphub.info, it doesn't work. For example, I tried to use (I'm not using my real API key below):

getIPinfo(df, "IPAddress", "MzM0OTprV1UxME1rWFFLZERHQ2VYOUJjWkFNT1Q2eEJodDZIRQ==")

with and without the "==" in the end of the API key, but none of the options worked.

I think this may be because my column "IPAddress" is a character vector. Otherwise, I don't know how else to proceed. Do you know why the function may not be working and how could I fix it?

Thanks for your help!

rkennedy01 commented 5 years ago

Hi @jospina88 -- I am sorry to hear about your issue with the package. I checked the package this morning and the IPAddress being shored as a character vector is not the issue (the call to the API simply appends the IPAddress to the API call). Indeed, because of the multiple periods in an IP address, R will introduce NAs if you try to convert it to a numeric variable.

Without more information, my best guess on why you are having difficulties is that there is something in your IPAddress variable that is not an IP address. This usually happens when there is a blank IP -- for example, I have audited a couple of surveys where people included their preview responses which do not record and IP address -- or where some other string has made its way into the IPAddress variable -- for example, not deleting extra headers Qualtrics automatically generates when you download the data or if a value from another column is incorrectly loaded into the IPAddress column. (We will try to add some safeguards against this in the next version of the package.)

Let me know if either of these fixes work for you. If not, please let us know if there are any error messages you are receiving and we can do further diagnoses.

Thanks! Ryan

On Wed, Oct 17, 2018 at 7:10 AM Philip Waggoner notifications@github.com wrote:

Hi @jpospina88 https://github.com/jpospina88 - sorry to hear you are having an issue with the function. I suspect you may be right about the vector being a character vector, and that being the problem. Before running the function, try: df$New.IPAddress <- as.numeric(df$IPAddress). Then, try: getIPinfo(df, "New.IPAddress", "MzM0OTprV1UxME1rWFFLZERHQ2VYOUJjWkFNT1Q2eEJodDZIRQ=="). Let us know if this doesn't work.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MAHDLab/rIP/issues/1#issuecomment-430603018, or mute the thread https://github.com/notifications/unsubscribe-auth/ATEjPuH8CIzB-wSnoLLmKSujy4U392vxks5ulx4ugaJpZM4Xi8Pw .

-- Ryan Kennedy, PhD Associate Professor Department of Political Science University of Houston

jpospina88 commented 5 years ago

Hi @rkennedy01 ,

Exactly, I tried to convert the IP addresses to numeric vectors and I got NAs.

I also double-checked my data and I don't have any missing IP addresses.

When I run the function:

getIPinfo(df, "IPAddress", "MzM0OTprV1UxME1rWFFLZERHQ2VYOUJjWkFNT1Q2eEJodDZIRQ==")

I get the following error:

Error in curl::curl_fetch_memory(url, handle = handle) : Illegal characters found in URL

Do you know why this may happen? Thank you!

rkennedy01 commented 5 years ago

Hi @jpospina88, That is a new error for us. It would seem to suggest that there is some strange character that is making its way into your API call. I recently updated the package to add a check for the validity of the IP address and create a warning message when a missing or incorrectly formatted IP address is found along with the location of the incorrect IP address. Try uninstalling the package and reinstalling it from GitHub. If that doesn't work, email me directly at rkennedy@uh.edu. I may need to take a peek at your data to see exactly where things are going wrong.

jpospina88 commented 5 years ago

Hi @rkennedy01,

I uninstalled it and reinstalled the package again from GitHub. Now the code works but I needed to install the package 'iptools' to make it work.

Thank you. Your team is the best, thanks for developing this function to check IP addresses!

rkennedy01 commented 5 years ago

Thanks @jpospina88 ! This is likely to affect other users as well. Really glad we were able to find a solution.