I require an Instagram User ID number to incorporate into a Google Script

My goal is to input a username into the following format:

https://www.instagram.com/{username}/?__a=1

I found this useful thread with a great tip on how to do it.

Next, I need to access that link using Java and retrieve the page code. Here's an example using professional skateboarder Nyjah Huston:

{"logging_page_id":"profilePage_8223552","show_suggested_profiles":false,"show_follow_dialog":false,"graphql":{"user":{"biography":"Sender\ud83d\ude08\n@nikesb @monsterenergy @elementbrand  @blackplaguebrewing @socialcbd @priverevaux","blocked_by_viewer":false,"restricted_by_viewer":null,"country_block":false,"external_url":"https://www.nike.com/t/sb-nyjah-free-skate-shoe-oKwn7N/AA4272-300","external_url_linkshimmed":"https://l.instagram.com/?u=https%3A%2F%2Fwww.nike.com%2Ft%2Fsb-nyjah-free-skate-shoe-oKwn7N%2FAA4272-300&e=ATMW9Q8NwN2Mcwm_Bd5I8DeuAKP4L7IHpy_PdylDnGU8qqokJU6Z1kh_emEIVfJ1q8Xtq1b0&s=1","edge_followed_by":{"count":3969537},"followed_by_viewer":false,"edge_follow":{"count":694},"follows_viewer":false,"full_name":"Nyjah Huston"

The User ID can be found at the beginning of the page:

{"logging_page_id":"profilePage_8223552"

In this case, the user id is 8223552. Since I am new to Java, I would appreciate guidance on how to navigate the link, extract the data, and convert the user id into a variable for use in my Google script. Thank you for your assistance!

Answer №1

If you only require specific information from this JSON content, consider parsing it into an object that contains only the necessary data:

class UserInformation{
    private String logging_page_id;
}

This approach is recommended because it allows for easy extension of the object in the future if additional information is needed.

For guidance on how to perform this conversion, you can refer to this stackoverflow thread.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Securing WCF in XML-based AJAX service

Is there a way to add security using the http://msdn.microsoft.com/en-us/library/bb472488.aspx resource? Specifically, I am looking to restrict data posting to users from the domain: DOMAIN\User1 and DOMAIN\User2. Thank you. ...

Tips for safely incorporating authentication information into routing in a React application

Introduction In my application, the backend is responsible for user authentication while the front-end handles user authorization for routing purposes. After a user logs in, a unique user UID is returned from Firebase. Currently, I am storing this UID in ...

Issues with touch listener functionality in Android's imageview are causing inconven

Can anyone assist me with an issue I'm facing? My Imageview touch listener seems to not be working properly. imgShowNewAgain.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent e ...

Dynamically Deserializing JSON with Newtonsoft(Json.NET)

Here is an example of JSON data: {"id":"123456","active":true,"content":[],"Categories":[['Apples','Bananas','Oranges']]} I recently discovered the JSON.NET library for deserializing JSON in C#. If I were to use the followi ...

Retrieving every document from the server request in order to create a collection of list tiles within a

In my database titled "ProductDatabase," I keep records of all the available products. My goal is to send an authorized request to my server in order to receive a snapshot of all the documents stored there. import 'package:flutter/foundation.dart&apo ...

"The AJAX request triggers an internal 500 error whenever either a post or get request is

Whenever I attempt to submit a post or use the get method from my index.php file which calls Ajax_mysql.php through the Ajax function POST or GET, I encounter a frustrating Internal 500 error. The server doesn't provide any additional information abou ...

Sorting by numerical value in Angular

I have a JSON structure that looks like this - { "json" : [ { "200" : "5"}, { "302" : "6"}, { "400" : "1" } ] } My goal is to sort the data by the values in descending order, meaning I want the row with 6 to come first, then the ...

Tips for managing REST exceptions

We are currently discussing the best approach for handling REST exceptions. Response Content type: JSON Two proposed solutions: Throwing all unchecked exceptions as a JSON response. Sending an Invalid Response Code with the request. Arguments: Why r ...

How to insert an image of varying dimensions into a div using HTML5

How can I insert an image into a div container with different shapes such as rectangle, square, or circle using HTML5? I am looking for something similar to the example below Your assistance would be much appreciated ...

How to retrieve the response code when Android HttpUrlConnection returns an empty response

My code isn't returning any response, specifically, the Toast is empty. Can someone please help me identify the issue? I'm also unsure of how to extract the response code. Thank You register_btn.setOnClickListener(new View.OnClickListener() { ...

Create a Vue.js dropdown menu that dynamically changes options based on the capacity of different trips

Imagine a scenario where a user has planned a trip with a specific capacity to accommodate a certain number of individuals. For instance, the trip may be designed for 1 person or up to 6 people. To streamline the process of calculating the total trip price ...

What are the steps to troubleshoot a NullPointerException error in apache.jena.queryExecutionFactory while attempting to create

Currently, I am utilizing org.apache.jena with karaf. When attempting to query my model, I encountered a NullPointerException. After examining all the variables used in creating the query (queryString, inferedModel), none of them are null. Here is a snippe ...

"Efficiently organizing tasks in AngularJS: Utilize Factories for Submitting and Deleting Functions in

While developing a simple To Do App, I noticed that my Controller was getting cluttered with too much code. This made me realize the need to move some of my functions into factories in order to maintain clean and readable code. Below is my JavaScript code ...

Receiving a 500 status code upon converting a SqlDataReader into Json format

Getting a status 500 error and not sure where I am going wrong. When I click on the 'Getcustomers' button, the 'GetCustomers' method is called which returns JSON. Script: <script> var MyApp = angular.module("MyApp", []); ...

AngularJS Bootstrap: Generating Pop-up Windows

In my AngularJS & Bootstrap application, I implemented a popup that appears when an image is clicked. However, the issue I'm encountering is that the same image and polygon are displayed in each popup. I am looking to have each image paired with its o ...

Understanding the functionality of a loop with a nested array

I'm currently trying to comprehend how this array functions within a loop for (int answer=0; answer<responses.length; answer++) { ++frequency[responses[answer]] } The 'Frequency' array is initialized as follows: int [] frequency = new ...

Having difficulty reliably loading a sizable JSON response with jquery.ajax

Recently, I encountered an issue with one of my scripts that retrieves a json response from the server. The script uses jquery.ajax() to make an ajax call. Here is the code snippet: var request = $.ajax({ url: "script.jsp", type: "POST", dataType: " ...

Troubleshooting: Else block not functioning as expected within a React JS map function

I have a notification feature that makes an API call every 10 seconds to display an alert based on the response. However, I'm encountering an issue where the div is not being rendered properly. The div should be displayed based on certain conditions w ...

Jquery slide animation not functioning properly

Hello, I am attempting to create a sliding effect for specific text where the slide effect adds something similar to extra spacing. The desired effect can be seen here: like margin or something, the framework being used is . My question is: Is there a wa ...

"Implement a script in Python to substitute a keyword for a specific data key

How can I update an old JSON file where the key names 'logic_1' and 'logic_2' are changed to just 'logic'? (Note: The data is retrieved from a JSON file with multiple entries obtained through a loop) [ { "logic_1" ...