Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用instagram api获取带有特定标签的图像?_Php_Javascript_Api_Instagram - Fatal编程技术网

Php 如何使用instagram api获取带有特定标签的图像?

Php 如何使用instagram api获取带有特定标签的图像?,php,javascript,api,instagram,Php,Javascript,Api,Instagram,最近,我正在学习instagram api,以便在我的网站上获取某些标签图像 在网上搜索了很长一段时间后,我发现没有任何可行的代码 有人能帮忙吗 谢谢 您将需要使用API端点来通过哈希标记获取最近标记的媒体列表。为标签“superpickle”获取媒体可能会像这样 https://api.instagram.com/v1/tags/superpickle/media/recent 您需要阅读Instagram API文档以了解更多信息以及如何注册客户端ID。您可以使用Staticgram cU

最近,我正在学习instagram api,以便在我的网站上获取某些标签图像

在网上搜索了很长一段时间后,我发现没有任何可行的代码

有人能帮忙吗


谢谢

您将需要使用API端点来通过哈希标记获取最近标记的媒体列表。为标签“superpickle”获取媒体可能会像这样

https://api.instagram.com/v1/tags/superpickle/media/recent

您需要阅读Instagram API文档以了解更多信息以及如何注册客户端ID。

您可以使用Staticgram cURL方法,而不是Instagram API,但可以解决此问题。 Im使用CodeIgniter并创建一个服务来返回XML,使用Sign simple_XML_load来读取提要。 祝你好运

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_URL, "http://statigr.am/feed/cristiano");
$content = curl_exec($curl);
curl_close($curl);

$this->xml = simplexml_load_string($content, 'SimpleXMLElement', LIBXML_NOCDATA);

echo json_encode($this->xml->channel);

如果您只需要基于标记显示图像,则不需要包含包装类“instagram.class.php”。因为Instagram API中的媒体和标签端点不需要身份验证。可以使用以下基于curl的函数根据标记检索结果

function callInstagram($url)
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
));

$result = curl_exec($ch);
curl_close($ch);
return $result;
}

$tag = 'YOUR_TAG_HERE';
$client_id = "YOUR_CLIENT_ID";

$url = 'https://api.instagram.com/v1/tags/'.$tag.'/media/recent?client_id='.$client_id;

$inst_stream = callInstagram($url);
$results = json_decode($inst_stream, true);

//Now parse through the $results array to display your results... 
foreach($results['data'] as $item){
    $image_link = $item['images']['low_resolution']['url'];
    echo '<img src="'.$image_link.'" />';
}
函数callInstagram($url)
{
$ch=curl_init();
curl_setopt_数组($ch,数组(
CURLOPT_URL=>$URL,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_SSL_VERIFYPEER=>false,
CURLOPT_SSL_VERIFYHOST=>2
));
$result=curl\u exec($ch);
卷曲关闭($ch);
返回$result;
}
$tag='YOUR_tag_HERE';
$client\u id=“您的\u client\u id”;
$url='1https://api.instagram.com/v1/tags/“.$tag.”/media/recent?client_id=”.$client_id;
$inst_stream=callInstagram($url);
$results=json_decode($inst_stream,true);
//现在分析$results数组以显示结果。。。
foreach($results['data']作为$item){
$image_link=$item['images']['low_resolution']['url'];
回声';
}

您好,我有一个带下划线的标签,我正在使用这段代码,除了带下划线的标签之外,所有标签都可以正常工作。现在需要oAuth访问