国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Before You Begin
Basic Display API
The User Endpoint
The Edge Endpoints
Other Endpoints on the Instagram Graph API
What Platforms Does the Instagram API Support?
What's Next?
More Coding For Social Media Tutorials
Home Backend Development PHP Tutorial Introduction to the Instagram API

Introduction to the Instagram API

Mar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.

As a developer building an app that requires information from a user's authorized Instagram account, your choice of the two APIs depends on the scope of information you want regarding the user.

If you just want basic profile information about the user or a collection of the media (photos, videos, and albums) on their account, then the Basic Display API will suffice.

However, if you want to get more intricate social media interactions data, metrics, and insights about Instagram Businesses and Creator accounts, then you'll require the Instagram Graph API.

In this tutorial, you'll learn about the Instagram developer API. I'll give you a broad overview of what you can do with both sets of APIs and how to get started.

Before You Begin

To make use of the Instagram API, you'll need to first create and configure an OAuth app in the App dashboard on your Facebook developer account. This process should result in you getting an API access token, which you'll use in every request to the API.

Please keep in mind that there are two different guides for setting things up:

  • If you want permission to call the Instagram Graph API with your app, follow this guide.
  • If you want permission to read basic profile information on an Instagram account (aka Instagram Basic Display API), follow this guide instead.

You should also note that your ability to use certain APIs may depend on the permissions you set for each token in the App dashboard. For this reason, I suggest that you first read this article to see which permission is required for which task.

Using the access token from your app, you can query the API with any HTTP client of your choice.

Basic Display API

With the Instagram Basic Display API, you can tell users of your app to grant you permission to get basic profile information, photos, and videos on their Instagram accounts. The API was created for non-Business and non-Creator Instagram users.

The User Endpoint

The User endpoint allows you to look up basic information about an Instagram user based on their User ID. To use this API, your request must include an Instagram User Access Token, and the following permissions must be enabled on your Instagram OAuth app:

  • instagram_graph_user_media (this is required only if you want the user's api-version (optional): The API version, e.g. v14.0 (learn more about versions in the Instagram API documentation). The value must be a string.
  • fields (optional): A comma-delimited list of the fields and edges you want to be returned by the API. If omitted, the default fields will be returned.
  • account_type, media_count, and /me is mapped to caption, media_type, username, permalink, and instagram_graph_user_media permission and returns a single object by its Media ID.

    For example, here's a sample cURL request:

    curl -X GET \<br>  'https://graph.instagram.com/13445686989093505?fields=id,media_type,media_url,username,timestamp&access_token=IGQVJ...'<br>

    And here's a sample response:

    {<br>  "id": "13445686989093505",<br>  "media_type": "IMAGE",<br>  "media_url": "https://fb-s-b-a.akamaihd.net/...",<br>  "username": "ubahthebuilder"<br>  "timestamp": "2022-07-20T18:10:00+0000"<br>}<br>

    The Edge Endpoints

    Edges allow you to get additional information about an Instagram user or media. You can request an edge as a path parameter or by using the fields and caption, media_type, username, permalink, and shopping_product_tag_eligibility field for product tagging)

  • instagram_shopping_tag_products (same as the above)

The API also requires the following on the part of the app user you're intending to retrieve information about (Note: This is only needed if you intend to request the api-version (optional): The API version, eg. v14. The value must be a string.

  • fields (optional): A comma-separated list of the fields and edges you want to be returned by the API. If omitted, the default fields will be returned.
  • biography, followers_count, follows_count, name, shopping_product_tag_eligibility, website. The following image describes what each of these fields returns.Introduction to the Instagram API

    For example, here's a sample cURL request from the docs:

    curl -X GET \<br>  'https://graph.facebook.com/v14.0/17841405822304914?fields=biography%2Cid%2Cusername%2Cwebsite&access_token=EAACwX...'<br>

    And here's the sample response:

    {<br>  "biography": "Dino data crunching app",<br>  "id": "17841405822304914",<br>  "username": "metricsaurus",<br>  "website": "https://www.metricsaurus.com/"<br>}<br>

    In addition, the IG User endpoint supports various edges which allow the app to get additional information about the Business or Creator account. These edges are described in the following image.

    Introduction to the Instagram API

    To get any of these data, you simply need to include the corresponding Edge as an additional path parameter to the IG User endpoint. For example, the following endpoint gets a collection of media on an IG User:

    GET https://graph.facebook.com/{api-version}/{ig-user-id}/media<br>  ?fields={fields}<br>  &access_token={access-token}<br>

    Other Endpoints on the Instagram Graph API

    The remaining APIs for working with Business and Creator accounts are:

    • IG Media: This allows you to retrieve information about an Instagram photo, video, or album by the Instagram media ID.
    • IG Hashtag: This allows you to retrieve information about a given Instagram hashtag.
    • IG Hashtag Search: This root edge allows you to get Instagram hashtag IDs.
    • IG Container: This allows you to retrieve information about a media container's publishing status. A media container is used for publishing an Instagram post.
    • IG Comments: This allows you to retrieve comments on a media by the Instagram comment ID. Information returned from the API includes replies to the comment, the like count, and the comment text.

    Note that each of these API endpoints may require different OAuth scope permissions on your Instagram app, support a different combination of fields and edges, or have certain limitations placed on its usage. As such, make sure to read the complete Instagram API documentation for clarity.

    What Platforms Does the Instagram API Support?

    You can access the Instagram API with any platform or programming language using its REST endpoints.

    Most programming languages come with a built-in HTTP Client API or a third-party library for making API requests. Examples are axios (Node.js), Net::HTTP (Ruby), requests (Python), and guzzlehttp/guzzle (PHP).

    What's Next?

    I hope you're intrigued to begin using the Instagram API. To get started, simply create a Facebook developer account, refer to the Getting Started guide for instructions on how to retrieve your API token, and start querying the API!

    More Coding For Social Media Tutorials

    We've seen some Instagram API examples in this article. It's time to

  • The above is the detailed content of Introduction to the Instagram API. For more information, please follow other related articles on the PHP Chinese website!

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Hot Topics

    PHP Tutorial
    1502
    276
    PHP Variable Scope Explained PHP Variable Scope Explained Jul 17, 2025 am 04:16 AM

    Common problems and solutions for PHP variable scope include: 1. The global variable cannot be accessed within the function, and it needs to be passed in using the global keyword or parameter; 2. The static variable is declared with static, and it is only initialized once and the value is maintained between multiple calls; 3. Hyperglobal variables such as $_GET and $_POST can be used directly in any scope, but you need to pay attention to safe filtering; 4. Anonymous functions need to introduce parent scope variables through the use keyword, and when modifying external variables, you need to pass a reference. Mastering these rules can help avoid errors and improve code stability.

    How to handle File Uploads securely in PHP? How to handle File Uploads securely in PHP? Jul 08, 2025 am 02:37 AM

    To safely handle PHP file uploads, you need to verify the source and type, control the file name and path, set server restrictions, and process media files twice. 1. Verify the upload source to prevent CSRF through token and detect the real MIME type through finfo_file using whitelist control; 2. Rename the file to a random string and determine the extension to store it in a non-Web directory according to the detection type; 3. PHP configuration limits the upload size and temporary directory Nginx/Apache prohibits access to the upload directory; 4. The GD library resaves the pictures to clear potential malicious data.

    Commenting Out Code in PHP Commenting Out Code in PHP Jul 18, 2025 am 04:57 AM

    There are three common methods for PHP comment code: 1. Use // or # to block one line of code, and it is recommended to use //; 2. Use /.../ to wrap code blocks with multiple lines, which cannot be nested but can be crossed; 3. Combination skills comments such as using /if(){}/ to control logic blocks, or to improve efficiency with editor shortcut keys, you should pay attention to closing symbols and avoid nesting when using them.

    Tips for Writing PHP Comments Tips for Writing PHP Comments Jul 18, 2025 am 04:51 AM

    The key to writing PHP comments is to clarify the purpose and specifications. Comments should explain "why" rather than "what was done", avoiding redundancy or too simplicity. 1. Use a unified format, such as docblock (/*/) for class and method descriptions to improve readability and tool compatibility; 2. Emphasize the reasons behind the logic, such as why JS jumps need to be output manually; 3. Add an overview description before complex code, describe the process in steps, and help understand the overall idea; 4. Use TODO and FIXME rationally to mark to-do items and problems to facilitate subsequent tracking and collaboration. Good annotations can reduce communication costs and improve code maintenance efficiency.

    How Do Generators Work in PHP? How Do Generators Work in PHP? Jul 11, 2025 am 03:12 AM

    AgeneratorinPHPisamemory-efficientwaytoiterateoverlargedatasetsbyyieldingvaluesoneatatimeinsteadofreturningthemallatonce.1.Generatorsusetheyieldkeywordtoproducevaluesondemand,reducingmemoryusage.2.Theyareusefulforhandlingbigloops,readinglargefiles,or

    Learning PHP: A Beginner's Guide Learning PHP: A Beginner's Guide Jul 18, 2025 am 04:54 AM

    TolearnPHPeffectively,startbysettingupalocalserverenvironmentusingtoolslikeXAMPPandacodeeditorlikeVSCode.1)InstallXAMPPforApache,MySQL,andPHP.2)Useacodeeditorforsyntaxsupport.3)TestyoursetupwithasimplePHPfile.Next,learnPHPbasicsincludingvariables,ech

    How to access a character in a string by index in PHP How to access a character in a string by index in PHP Jul 12, 2025 am 03:15 AM

    In PHP, you can use square brackets or curly braces to obtain string specific index characters, but square brackets are recommended; the index starts from 0, and the access outside the range returns a null value and cannot be assigned a value; mb_substr is required to handle multi-byte characters. For example: $str="hello";echo$str[0]; output h; and Chinese characters such as mb_substr($str,1,1) need to obtain the correct result; in actual applications, the length of the string should be checked before looping, dynamic strings need to be verified for validity, and multilingual projects recommend using multi-byte security functions uniformly.

    Quick PHP Installation Tutorial Quick PHP Installation Tutorial Jul 18, 2025 am 04:52 AM

    ToinstallPHPquickly,useXAMPPonWindowsorHomebrewonmacOS.1.OnWindows,downloadandinstallXAMPP,selectcomponents,startApache,andplacefilesinhtdocs.2.Alternatively,manuallyinstallPHPfromphp.netandsetupaserverlikeApache.3.OnmacOS,installHomebrew,thenrun'bre

    See all articles