从instagram图片网址中提取用户和标题 [英] extract user and caption from instagram image URL

查看:193
本文介绍了从instagram图片网址中提取用户和标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用instagram API从照片URL中提取发布了照片和与照片相关的标题的用户.

例如:

图片网址为: http://instagram.com/p/rRoE9uskcD/

如何从中提取用户和标题?

解决方案

您实际上只需要使用Instagam的嵌入端点

因此,此链接:

http://api.instagram.com/oembed?url=http://instagr.am/p/rRoE9uskcD/

将以json格式返回与此类媒体相关的信息.

您可以在ajax函数中以编程方式获取信息,例如:

var url = "http://api.instagram.com/oembed?url=http://instagr.am/p/rRoE9uskcD/";
jQuery(document).ready(function ($) {
    $.ajax({
        url: url,
        dataType: "jsonp", // <== this is important
        cache: false,
        success: function (data) {
            console.log(data.author_name); // the author
            console.log(data.title); // the caption (if any)
        }
    });
});

请参见 JSFIDDLE

I want to extract the user who has posted the photo and caption associated with the photo from the photo URL using instagram API.

For example:

The image URL is: http://instagram.com/p/rRoE9uskcD/

How can I extract user and caption from this ?

解决方案

You actually only need to use Instagam's Embedding Endpoints

so this link :

http://api.instagram.com/oembed?url=http://instagr.am/p/rRoE9uskcD/

will return the info associated with such media in a json format.

You can get the info programmatically inside an ajax function like:

var url = "http://api.instagram.com/oembed?url=http://instagr.am/p/rRoE9uskcD/";
jQuery(document).ready(function ($) {
    $.ajax({
        url: url,
        dataType: "jsonp", // <== this is important
        cache: false,
        success: function (data) {
            console.log(data.author_name); // the author
            console.log(data.title); // the caption (if any)
        }
    });
});

See JSFIDDLE

这篇关于从instagram图片网址中提取用户和标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆