Integration of REST-Based Web Service and Browser Extension for Instagram Spam Detection

In this paper, a REST-based Web Service developed in previous work was integrated with a newly developed browser extension that works in modern browser (Firefox and Google Chrome) using Greasemonkey. It uses previous collected datasets which comprised of 17.000 postings and comments from 10 Indonesian actresses whom followers are more than 10 million on Instagram. The performance of the developed web services has been evaluated and the average response time is 1678.133ms using AWS platform located in Ohio (US East 2). The proposed work is working as expected and in accuracy test, it has reached 63.125% in overall, 72% for nonstemmed data and 70% for stemmed data using 1000 test data with a processing time needed for classification is under 2s. The new extension works in Firefox and Chrome and it can utilize the web services to classify spam comments in Instagram. Keywords—Instagram; spam comments; REST service; web service testing; browser extension


INTRODUCTION
Social media is no longer just a mean for sharing information along relatives and colleagues, but it has transformed into a bigger scope and touching every aspect of human life.Social media is already used in many situations, like emergency situation [1], traveling [2], and health [3].However, it comes with a price.According to [4], [5], and [6] there are a lot of spam comments in media social, such as YouTube, Facebook, Twitter, and Instagram.These spammers may cause some information misleading, mixed information, wasting valuable network resources, and decreasing the quality of online social networking sites [7], [8], and [9].
Nowadays, most people are using Instagram because of its characteristic of being an image-based social media.A picture speaks for thousand words by nature.According to [10], Instagram has reached 1 billion monthly users in June 2018, a significant raise from 800 million in September 2017.It shows that Instagram is gaining a huge popularity among many people, including Indonesian actress who proactively engaged with their fans to help them gain more popularity and brings more business opportunities for them.
Instagram is gradually introducing new features as posted in their press web sites (https://instagram-press.com/), but rarely seen a posting about spam detection.One of the reasons is that because spam may come in many ways and sometimes it's context-based, so it's hard to find a good balance for creating an algorithm that can detect spam comments nowadays, especially in Indonesian language.There is no implemented solution for automated Indonesian language spam detection in Instagram yet.Many previous work [11], [6], [12] used Instagram data for spam detection, but so far, there are no real implemented solution for spam detection.The research done so far was more focused on testing the accuracy of each model.Especially on Indonesian-based language, which according to [13] is still considered as one of the resource-poor languages.
In this paper, an implemented solution for automated Indonesian language spam detection is proposed by building an integration between a REST-based web service and a browser extension that can be used to detect Instagram spam comments in Indonesian language.This research contributes in enriching Indonesian language related researches and creates a ready to use Instagram spam detector.Browser extension is the option we chose since it allows us to interact with the content on Instagram without breaking same-origin policy [14].

II. RELATED WORK
Hardinata and Tirtawangsa [11] developed spam detector in Indonesian Twitter trending topics.The spam detector works by detecting spam that utilized trending topics hashtags.The spam detection process involved human input that collected using monster game interface.Zhang and Sun [15] has published their work on a model to decrease number of spam posts in Instagram, but only applicable for English language.Ali and Okiriza [12] published their work on detecting spam comments on Indonesia's Instagram post using three different algorithms: Naïve Bayes, SVM, and XGBoost.They concluded that SVM and XGBoost got the best scores of 0.9601 and 0.9512.In all the researches, not a single of them proposed a real implemented and practical solution since they all are focusing on the accuracy of the models being tested.This work was started in 2017 by building Indonesian spam comments detector using Naïve Bayes [16] and collected more than 25.000 postings and comments from Indonesian actress with more than 10 million followers.After data cleansing process, the final data used are 17.000 postings.From this datasets, some experiments were conducted using different algorithms and it was concluded that K-Nearest Neighbors (k-NN) gave the best results with 88.4% of accuracy [17], followed by Support Vector Machine with 78.5% [18], and Naïve Bayes with 75.5% [16].www.ijacsa.thesai.orgNext, a REST-based web service to detect Indonesian language Instagram spam comments using k-NN algorithm design was designed and deployed on top of AWS platform and evaluate the performance based on response time.[19].

A. Architecture
This work is using the same AWS architecture that was developed in previous work [19] for the web service architecture, which was deployed on US-East 2 region (Ohio).The system is using Tomcat as the main web server and all datasets are stored in the S3 bucket for durability and performance reason.The architecture is illustrated in Fig. 1.
The web service does not deploy SSL certificate for this machine as there are no confidential data that are communicated, and the system never stored any data transmitted to the server during spam detection process.The dataset is stored in the S3 bucket which is only accessible via the web server and not directly accessible for public.
All the communication between client (browser) and the server will be done using REST [20] which has some advantages over SOAP such as better throughput and response time, as demonstrated on [21] and [22].

B. Algorithm
In this work, k-NN algorithm is used based on previous work [17] that gives best results compared to other algorithms (Support Vector Machine [18] and Naïve Bayes [16]).K-NN is learning directly while performing classification process by finding some adjacent data object or patterns based on the input and choose a class with the highest number of patterns [19].K-NN can be implemented as follows (Fig. 2): 1) Load the data 2) Initialize the value of k  When user highlighted some text in Instagram posting, the extension will read the highlighted text and send it to the web service in AWS  Web service will process the request and reply the results back to the browser  Browser extension will display the results to user in form of a dialog box.

D. Evaluation
Several tests were conducted to evaluate some metrics.The first test was performed using SOAPUI tool which is used to perform load testing, method testing, simple load testing, burst load testing, thread load testing, variance load testing, and datadriven testing.It used 160 data for data-driven test.
The second test was testing the web service accuracy by using PHP scripts to automate the test.The test used 1000 random data taken from dataset using shuffled sampling.The dataset was generated using 10 smaller dataset which consisted of 100 data to reduce the slow processing time.Afterwards, it's merged with the rest.Next, the dataset is tested against 8 test datasets which have been stored in the web service already.The parameters used for the k-NN validation shown in Table 1.www.ijacsa.thesai.org

A. Web Service Accuracy
The results of the web service accuracy after tested against 8 datasets can be seen on the Table II

B. Web Service Comprehensive Testing a) Method Testing
This test is used to ensure the output of all the web service are according to what we expected in terms of formatting and the content itself.This is the simplest test but also crucial to be performed so that the system gives the same output as what it is expected to do.The result of the method testing can be seen on Table X.All the methods we developed have produced expected results.

b) Load Testing
This test is used to see how the system behaves under high load.The instance used in this work is t2 micro which only have 1 vCPU and 1 GB of RAM.In the first test, we used the Version method to represents GET method, with the following parameters:   In simple load test, it has minimal request of 252 ms, maximum request is 3280 ms, and average request is 521,58 ms.In burst load test, it has minimal request of 582 ms, maximum request is 582 ms, and average 582 ms.
In thread load test, it has minimal request 253 ms, maximum request is 3277 ms, and average is 503,58 ms.There are 11 requests that has more than 1000 ms (more than time limit of the system).The average request time is around 3 seconds.
In variance load test, it has minimal request of 251 ms, maximum request is 671 ms, and average is 494,93 ms.There are 9 requests that has more than 1000 ms (more than time limit of the system).The average request time is around 3 seconds.
The second test is the Classify method to represents POST method, with the following parameters: The result of the load testing is shown in Fig. 7, Fig. 8, Fig. 9, and Fig. 10.
In simple load test, it has minimal request about 0.5-6s, maximum request is 0.5-8ms, and average 0.5-6ms.In thread load test are, it has minimal request about 0.2-4s, maximum request is 0.2-3 ms, and average 0-0.7 ms.The system cannot continue all of the test data as it only finish 19 of 160 test data in 120s.In thread load test, it has minimal request about 0.4-11s, maximum request is 0.4-12ms, and average 0.4-12ms.The system cannot continue to load all the test data as it only finishes 87 of 160 test data in 120s.In variance load test, it has minimal request about 0.4-11s, maximum request is 0.4-12ms, and average 0.4-12ms.The system cannot continue all the test data as it only finished 87 of 160 test data in 120s.
The load testing results are summarized in      Version method is considerably faster than Classify method because it only returns static text, while Classify method is more slower because it does spam detection process.This characteristics is also shown in the simple and burst testing and thread and variance testing results.The Classify method performance is also affected by the length of the input and the size of the datasets used for spam detection process.c) Data Driven Testing Data driven test is using test data that has been stored in some external storage and use it iteratively.8 datasets were used in which each dataset consists of 20 test data and divided into 2 more categories: 10 data categorized as SPAM and 10 data categorized as NON-SPAM so in total, it has 160 tests.The metrics measured were response time and accuracy.The results can be seen in Table XIII.
The result of this accuracy on data driven test with SOAPUI are: the accuracy is 63.125 % and average response time is about 2 seconds.

C. Browser Extension Development
The browser extension was developed extensively for Mozilla Firefox since it was using Greasemonkey plugin although it is also working in Google Chrome.
The extension is dynamically detecting the URL loaded in the address bar.If it is coming from Instagram's URL, it will add a new entry in the context menu (right click menu) as the user highlight some comment as shown in Fig. 11.When user clicked the entry, it will send the text to the Classify method in our web services and it will return the results ('spam' or 'not spam') in clear text and show it to user Fig. 12.In Google Chrome, the results are displayed as inFig.13.
The browser extension developed is working as expected and able to do the spam detection process utilizing RESTbased web service that were deployed in earlier work.The extension's user interface still need some improvements to make it easier to use for common user.V. CONCLUSIONS In this paper, a browser extension for Firefox & Chrome has been successfully developed and integrated into a RESTbased web service [19] deployed on top of AWS Platform.Accuracy of the web service were measured using three datasets (whole datasets, 1000 stemmed dataset and 1000 nonstemmed dataset) and achieved accuracy level of 63.125% for whole datasets, 72% for non-stemmed dataset, and 70% for stemmed dataset.The average response time is under 2s, minimum load time test is between 0.2 -1.2s, and, maximum load time test is between 3 -7s.Although the browser extension is working as expected, the user interface and data accuracy still have room for improvements.

Fig. 2 .
Fig. 2. k-NN Algorithm 3) For getting the predicted class, iterate from 1 to total number of training data points: a) Calculate the distance between test data and each row of training data.Here we will use Euclidean distance as our distance metric since it's the most popular method.The other metrics that can be used are Chebyshev, cosine, etc. b) Sort the calculated distances in ascending order based on distance values c) Get top k rows from the sorted array d) Get the most frequent class of these rows e) Return the predicted class C. Browser Extension The browser extension is developed using Greasemonkey and works as follows:  Script will check visited page.If it is coming from Instagram, it will add a new entry in the browser's context menu (accessed via right click)

Number of threads: 10  5 
Intervals: 10 s  Variance: 0.Time limit: 1 s  Burst delay: 60 s  Burst duration: 10 s In load testing, there are 4 sub tests: simple, burst, thread, and variance.The result of the load testing are shown in Fig. 3, Fig. 4, Fig. 5, and Fig. 6.

TABLE I
through TableIX.

TABLE IV .
DATASET 3: BALANCED NON-STEMMED DATA GENERATED USING PHP

TABLE X
Table XI and Table XII.The description for the Table are: I is minimum load time, X is maximum load time, and A is Average load time.www.ijacsa.thesai.org

TABLE XI .
SUMMARY OF SIMPLE AND BURST TESTING

TABLE XII .
SUMMARY OF THREAD AND VARIANCE TESTING

TABLE XIII .
DATA DRIVEN TESTING RESULT