Question about the id on media items. The ids are in this form:
198319604945554515_31149514
What is the number after the _? And can I assume that the part before the _ is unique?
Apparently using just the first part in GetMedia queries works.
First you ask:
What is the number after the _?
That is the user ID for the media ID in question.
And can I assume that the part before the _ is unique?
Yes and no.
I’ve been experimenting with the Instagram API myself and have been curious about the media ID format, so tripped across this question and am posting an answer to expand on the comments already made.
Basically, the part before the _ is based on the timestamp connected with the media item itself; uploaded or creation I assume. This is based on johnnyg17’s comment—which is a correct assessment of the string format—and can be converted to Unix date format quite easily.
That said, the only true “uniqueness” of the ID comes from the combination of the part before the _ as well as the user ID after that.
Since the first part is clearly derived from a timestamp, and millions of users use Instagram all the time, the chances of multiple users uploading images with the same timestamp is quite high. It cannot be considered “unique” on its own since using just that number for ID purposes potentially runs into ID collisions which is definitely a scaling issue.
So the Instagram media ID gets around this issue by combining the timestamp-based item before the _ with the unique user ID that follows it. That combo is what makes the media ID unique.
And to prove that the first part of the ID is indeed based on a Unix timestamp — as johnnyg17’s comment explains — I whipped this up in PHP using some media IDs I have access to; the “user id” is of course changed to 123456789 to preserve privacy.
$test_array = array();
$test_array[] = "1388611234533808001_123456789";
$test_array[] = "1389294690389553994_123456789";
$test_array[] = "1390349053757443491_123456789";
$test_array[] = "1391541737234771515_123456789";
$test_array[] = "1392560455737690245_123456789";
$test_array[] = "1392592260868093320_123456789";
foreach ($test_array as $test_value) {
$split_string = mb_split('_', $test_value);
$unix_time = round(($split_string[0]/1000000000000 + 11024476.583915909500)/0.008388608000);
echo date("F j, Y, h:i:s a", $unix_time);
echo ' | ';
echo '<b>Instagram ID String</b>: ' . $split_string[0] . ' | <b>User ID</b>: ' . $split_string[1] . '<br />';
}
Running that produces the following output:
November 21, 2016, 02:09:40 pm | Instagram ID String: 1388611234533808001 | User ID: 123456789
November 22, 2016, 12:47:34 pm | Instagram ID String: 1389294690389553994 | User ID: 123456789
November 23, 2016, 11:42:24 pm | Instagram ID String: 1390349053757443491 | User ID: 123456789
November 25, 2016, 03:12:03 pm | Instagram ID String: 1391541737234771515 | User ID: 123456789
November 27, 2016, 12:56:04 am | Instagram ID String: 1392560455737690245 | User ID: 123456789
November 27, 2016, 01:59:15 am | Instagram ID String: 1392592260868093320 | User ID: 123456789
I believe the first part of the ids are unique, and will likely remain unique unless Instagram decides to change how they generate their URLs. Instagram encodes the first part of the id to determine what they call the media short-code. Which is then used in the last part of the URL of any public media:
https://www.instagram.com/p/BkvTIkEDkXs/
The below method can be used to base 64 encode the first part of the id into a shortcode. The id for the media above is:
1814753326215874028
Code below:
function idToShortCode($id)
{
$char_map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
$base = strlen($char_map);
$short = '';
while($id) {
$id = ($id - ($r = $id % $base)) / $base;
$short = $char_map{$r} . $short;
};
return $short;
}
The timestamp is only the first part of how they create their ids. The current ids are in the quintillions. My math may be off, but I'm pretty sure they can create ids at a rate of 1 billion a second before they run into issues generating ids.
So unless all 1 billion of their users have something to take a photo of at the same second, they should be good!
Related
Is there a way to have a paragraph of text get spit out when you have a certain input, from say a google questionnaire?
And make it so you could have say 5 inputs, and it would spit out 5 paragraphs of information, into one document?
For example:
If someone fills out a questionnaire where the first question is year of birth, the tool would spit out the first paragraph with a description of what the year they were born was like.
Second question would be their birth country, the tool would place a paragraph of text about their birth country into the document.
etc etc
Many thanks in advance for any help
It is possible to create documents using a specific criteria based in form responses. I created the following sample script using Google Apps Script so you can get the idea:
function docCreation() {
var ss = SpreadsheetApp.getActive().getSheetByName("Form Responses 1");
var range = ss.getDataRange();
var values = range.getValues().reverse(); //reverses the array to get the last value in the first position
var doc = DocumentApp.create("Testing doc"); // You can change the name to match a username or any other variable instead
switch (getMonth(values[0][1].toString())) {
case 'Aug':
doc.getBody().appendParagraph("This is a sample body for August");
break;
case 'Jul':
doc.getBody().appendParagraph("This is a sample body for July");
break;
}
}
// Second function that returns the month value of the date introduced by the user
// I separated it because it is not that relevant to the main goal
function getMonth(val){
var month = val.split(" ");
return month[1];
}
It is a very simple script that checks if the month of the date introduced by the user is August or July, and if so, it creates a doc with a simple text as paragraph.
The script is bounded to the Google Sheet of the form responses and you can create a trigger so that every time a user fills out the form, the script starts running to create the needed documents. Now as I mentioned, this is just a sample, and the logic and docs format would depend on your specific needs and usage.
References:
Class Body
Create document
Can someone briefly explain the differences between active users and page views in an azure workbook? I would like to get the stats of active users of a particular azure event, but the counts shown are not realistic for the provided scenario.
As per the attached image, there is only one active user, which has to be at least 3-4 and can go up to 15-16. The value displayed in Views is unrealistic though.
Your valuable inputs are highly appreciated. Thank you
if you edit the template/workbook and look at the queries you can see exactly what is going on there:
let start = startofday(ago({Metric}));
union customEvents, pageViews
| where timestamp >= start
| where name in ({Activities}) or '*' in ({Activities}) or ('%' in ({Activities}) and itemType == 'pageView') or ('#' in ({Activities}) and itemType == 'customEvent')
{OtherFilters}
| summarize Users = dcount(user_Id), Sessions = dcount(session_Id), Views = count()
| evaluate narrow()
| project Title = case(Column == 'Users', 'Active Users', Column == 'Sessions', 'Unique Sessions', 'Views'), Metric = Value, SubTitle = '━━'
views in this case, is a count of items in the tables; Views = count(),
Users is dcount(user_Id) and Sessions = dcount(session_Id)
seeing just 1 user/session implies that there's nothing automatically generating "distinct" ids for those values, so the user_Id, session_Id fields are completely empty across all rows (the one unique id being undefined in both columns)
how user and session id values get populated is very specific to what application insights sdks you are using, and how you've configured them.
I am using the below Kusto query for exporting logs from App insight log
traces
| extend request = parse_json(tostring(parse_json(customDimensions).PayloadMessage))
| extend message = request.message
| extend SecondaryInfo = request.SecondaryInfo
| extend Logtype = request.Logtype
| extend File = request.File
| extend LineNo = request.LineNo
| extend MemberName = request.MemberName
| extend User = split(split(message,'User(').[1],')').[0]
| project timestamp,message,SecondaryInfo,Logtype,File,LineNo,MemberName,User
I want to extract the email address from the message column. So I am using split operation. However, I could not find the correct logic to extract the email address. Could someone please share some regex.
Below are some values in the messages column
-MMS.Core.Logging.MmsException: 1012 - Error while fetching Room Booking Requests for (User: TestAccount100#fr.domain.com) at
-MMS.Core.Logging.MmsException: 1011 - Error while fetching User's Locations (TestAccount100#fr.domain.com) at"
RbacRepository.GetUserCityBuildings-correlationId-11111fd6-e111-4d11-1111-11e101fbe111--DT-04162021T084110893-- START: (Email:TestAccount100#fr.domain.com), Cities mapped 4"
RoomBookingDetailsRepository.GetRequestDetailsAsync: Getting the BookingDetails data for User(TestAccount100#fr.domain.com), Role(Admin), IsAdmin(True), PPED() Status(), AssignedTo ()"
Below is an example that uses a naive regex.
You can go over the documentation for RE2 to adjust it, if required: https://github.com/google/re2/wiki/Syntax
datatable(s:string)
[
"-MMS.Core.Logging.MmsException: 1012 - Error while fetching Room Booking Requests for (User: TestAccount100#fr.domain.com) at",
"-MMS.Core.Logging.MmsException: 1011 - Error while fetching User's Locations (TestAccount100#fr.domain.com) at",
"RbacRepository.GetUserCityBuildings-correlationId-11111fd6-e111-4d11-1111-11e101fbe111--DT-04162021T084110893-- START: (Email:TestAccount100#fr.domain.com), Cities mapped 4",
"RoomBookingDetailsRepository.GetRequestDetailsAsync: Getting the BookingDetails data for User(TestAccount100#fr.domain.com), Role(Admin), IsAdmin(True), PPED() Status(), AssignedTo ()",
]
| extend email = extract(#"(\w+#\w+\.\w+)", 1, s)
Hi I have google spreadsheet that contains customers' ID and their shipping status. I want to create google form where customers are able to input each of their own ID, with the return that the google form shows their shipping status.
I tried to look for solutions in internet but there was no luck. I am not really good in programming, i hope there is answer to this problem without having me to do some hard programming.
The sample case can be seen in here: https://docs.google.com/spreadsheets/d/14vSAeZxEJTzbNLLYEiref6qt-CMqiVi8alheLcIBugM/edit?usp=sharing
Google form should show something a little bit like is shown in cell D1:E3.
Where customers can fill the form with their own customer id, and the google form shows the status.
Consideration
There is no way to respond back in a Google Form directly. You can't show custom validation messages after From submission either.
Proposed solution
What about using email addresses additionally to the customerID to retrieve the shipping status? In this way you can easily build a notification system that will send an email if a matching customer ID is found in your spreadsheet.
To build such system you will have to build a Form with a Trigger.
It is required a bit of programming but I will try to cover the most important parts the best I can:
Adapt your Database structure
Add the customers email addresses in the column C in order to be able to retrieve it using the same customer ID.
| A | B | C |
|----+--------+-------|
| ID | STATUS | EMAIL |
Build the Form Trigger
In the Form you are using click on the 3 dots from the top menu and select Script Editor. Here you will write the code that will power your notification system.
function installTrigger() {
// This function instructs the program to trigger the checkID function whenever a form response is submitted
ScriptApp.newTrigger('checkID')
.forForm(FormApp.getActiveForm())
.onFormSubmit()
.create();
}
function checkID(e) {
// This function will parse the response to use the customer ID to retrieve email address and shipping status from the Spreadsheet Database
var responses = e.response.getItemResponses(); // Gets the form responses
var id = responses[0].getResponse(); // Assuming the first answer (index 0) is the customer ID)
var found = SpreadsheetApp.openById('spreadsheet_id')
.getRange('Sheet1!A1:C8') // The spreadsheet cells range in A1 Notation
.getValues() // Retrieve their values in rows
.filter((row) => row[0] == id); // Filter the rows for the provided customer ID
if (found) {
var status = found[0][1]; //Column B
var email = found[0][2]; //Column C
var subject = "Shipping Status";
var message =
`Hello!
The status of the order number ${id} is: ${status}.`
MailApp.sendEmail(email, subject, message);
}
}
Install the trigger
From the Script Editor top menu run the installTrigger() function: Run>Run function>installTrigger.
You are done
Following these steps you have successfully set up the notification system. Now you can start sharing the Form link and accept responses.
References
Installable Triggers
Mail App
I basically want to check if a particular user is free in a provided time range using QueryScheduleRequest. For this I am using the following piece of code to retrieve available timings of the user on today's date:
QueryScheduleRequest scheduleRequest = new QueryScheduleRequest
{
ResourceId = userResponse.UserId,
Start = DateTime.Today,
End = DateTime.Today,
TimeCodes = new TimeCode[] { TimeCode.Available}
};
QueryScheduleResponse scheduleResponse = (QueryScheduleResponse)serviceProxy.Execute(scheduleRequest);
However, I am not getting proper response in scheduleResponse as seen in CRM service calendar. The start and end dates are also getting changed in the response. For eg, say I enter Start and End date as 12th in scheduleRequest but in scheduleResponse they get changed to 12th and 13th respectively. I have checked that I am referring the correct user.
This is how the user's schedule looks like in CRM (Work Hours:10am to 7pm):
And this is how the result in scheduleResponse looks like:
Observe the dates and schedule getting changed. Is there any other way in which I can achieve this functionality?
Basically Dynamics CRM stores all dates in the database as UTC time.Crm Users has to convert into Users LocalTime.
After getting scheduleResponse. You can Use the below Code to get User Start time and End Time.
QueryScheduleResponse scheduleResponse = (QueryScheduleResponse)service.Execute(scheduleRequest);
foreach (var getTimings in scheduleResponse.TimeInfos)
{
DateTime startTime =Convert.ToDateTime(getTimings.Start.Value.ToLocalTime());
DateTime endTime = Convert.ToDateTime(getTimings.Start.Value.ToLocalTime());
}
Note:we have ExpandCalendarRequest Class also to Retrieve User Available Timings