Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'shortcode_media' of undefined #261

Open
WilliamTraoreee opened this issue Jun 17, 2021 · 8 comments
Open

Cannot read property 'shortcode_media' of undefined #261

WilliamTraoreee opened this issue Jun 17, 2021 · 8 comments

Comments

@WilliamTraoreee
Copy link

WilliamTraoreee commented Jun 17, 2021

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

@MonsieurBibo
Copy link

Hey, could you share your entire code please ? Thanks.

@ronaldho
Copy link

ronaldho commented Oct 23, 2021

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

@ronaldho
Copy link

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

@ronaldho
Copy link

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

@ronaldho
Copy link

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

@PedroBatistop
Copy link

same problem here

@eileenhlee
Copy link

same problem here too.

@nfarooq17
Copy link

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

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants