Cannot read property 'shortcode_media' of undefined
Hello
I have a problem with "getMediaByShortcode" endpoint, I have the error :
TypeError: Cannot read property 'shortcode_media' of undefined
Thanks a lot for the help
Hey, could you share your entire code please ? Thanks.
I also had the same problem this morning suddenly. The app was working perfectly fine up to 12 hours ago.
Example Post URL: https://www.instagram.com/p/CHAIm2sHSQZ/
I injected a console log into the getMediaByShortcode method in index.js
{ items:
[ { taken_at: 1604134864,
pk: 2431981653214438400,
id: '2431981653214438425_42241297565',
device_timestamp: 391120207524693,
media_type: 2,
code: 'CHAIm2sHSQZ',
client_cache_key: 'MjQzMTk4MTY1MzIxNDQzODQyNQ==.2',
filter_type: 0,
is_unified_video: false,
user: [Object],
can_viewer_reshare: true,
caption_is_edited: false,
like_and_view_counts_disabled: false,
liker_config: [Object],
featured_products_cta: null,
is_commercial: true,
commerciality_status: 'not_commercial',
is_paid_partnership: false,
playlist_eligibility: true,
comments_disabled: true,
title: 'What happens next is up to us',
product_type: 'igtv',
nearly_complete_copyright_match: false,
media_cropping_info: [Object],
thumbnails: [Object],
igtv_exists_in_viewer_series: false,
is_post_live: false,
image_versions2: [Object],
original_width: 540,
original_height: 840,
like_count: 251107,
has_liked: false,
top_likers: [Array],
facepile_top_likers: [Array],
photo_of_you: false,
can_see_insights_as_brand: false,
is_dash_eligible: 1,
video_dash_manifest: //omitted for brevity,
video_codec: 'avc1.64001F',
number_of_qualities: 4,
video_versions: [Array],
has_audio: true,
video_duration: 86.633,
view_count: 1496727,
caption: [Object],
can_viewer_save: true,
organic_tracking_token:
'eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiMDJjN2MxY2RlNTRjNDk4ZGI5MzQ0MDYzYmU3NzM4Y2EyNDMxOTgxNjUzMjE0NDM4NDI1Iiwic2VydmVyX3Rva2VuIjoiMTYzNTAyMjMzNTM0NXwyNDMxOTgxNjUzMjE0NDM4NDI1fDQ1MDkwNDk1MTIzfGM4YjA4MmQ4NTc1MDA4YzRhNjk4ZWUwYWQzYjRmODVhNDI3YTU4MTM5N2IzMTQ4YmIyY2FjMTk5YmNmNTI2ODYifSwic2lnbmF0dXJlIjoiIn0=',
sharing_friction_info: [Object],
is_in_profile_grid: false,
profile_grid_control_enabled: false,
deleted_reason: 0,
integrity_review_decision: 'approved',
music_metadata: [Object] } ],
num_results: 1,
more_available: false,
auto_load_more_enabled: false }
Not sure if this is a permanent change, but at least the original data structure is different now... data.graphql.shortcode_media does not seem to exist.
the weird thing is if i go to https://www.instagram.com/p/CHAIm2sHSQZ/?__a=1
{"graphql":{"shortcode_media":{"__typename":"GraphVideo","id":"2431981653214438425","shortcode":"CHAIm2sHSQZ","dimensions":{"height":995,"width":640},"gating_info":null,"fact_check_overall_rating":null,"fact_check_information":null,"sensitivity_friction_info":null,"sharing_friction_info":
...
then graphQL key is present, so im not sure why there is a discrepency
Okay, I did a bit more digging, one of my accounts returns the top result under items, but if i view the same post URL with the ?__a=1, then it returns the graphql format
if i try to match the params from the new items array to match the previous params from getMediaShortcode, and then try to like or submit a comment, I get this response
Name: StatusCodeError StatusCode 400 message: 400 - "Sorry, this photo has been deleted" Error: "Sorry, this photo has been deleted" URI: /web/likes/{id}/like/ Form: undefined
but i know for a fact that its not deleted
Okay, It was my mistake earlier, I thought the new "PK" key and the ID key is the same, but actually it is not, so i used a regex to lop off the numbers after the underscore.
After that I did some other mapping in my code to account for the place where data moved around
But hopefully this is a temporary change and not a shift to where the getMediaByShortcode is going towards
same problem here
same problem here too.
Okay, I did a bit more digging, one of my accounts returns the top result under
items, but if i view the same post URL with the?__a=1, then it returns thegraphqlformat
@ronaldho Hey can you guide me how are you getting posts URLs from your account, I have searching for media IDs but I could not find any way to get media ids of my posts then I am trying to get posts URLs so I can extract media ids from them.