本文整理汇总了PHP中Instagram::getUserMedia方法的典型用法代码示例。如果您正苦于以下问题:PHP Instagram::getUserMedia方法的具体用法?PHP Instagram::getUserMedia怎么用?PHP Instagram::getUserMedia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instagram
的用法示例。
在下文中一共展示了Instagram::getUserMedia方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instagram
public function instagram()
{
$id = '1600192808';
set_time_limit(0);
ini_set('memory_limit', '-1');
ini_set('max_execution_time', '999999');
require APPPATH . 'third_party/Instagram/Instagram.php';
require APPPATH . 'third_party/Instagram/InstagramException.php';
$config = '2440e15f188a41439c6edcd698ff081f';
$instagram = new Instagram($config);
$response = $instagram->getUserMedia($id);
while ($response && count($response->data)) {
if ($response->meta->code != 200) {
print_r($response);
exit;
}
$items = $response->data;
foreach ($items as $item) {
if (!isset($item->images->standard_resolution->url)) {
continue;
}
$link = $item->link;
$sql = "select * from instagram where link = '{$link}'";
$row = $this->db->query($sql)->row();
if ($row) {
die('FINISH');
}
$file = str_replace(array('https://instagram.com/p/', '/'), '', $link) . '.jpg';
$folder = 'instagram/';
$url = $item->images->low_resolution->url;
copy($url, FCPATH . 'files/' . $folder . $file);
$this->db->insert('nz_file', array('id_folder' => 28, 'id_type' => 1, 'file' => $folder . $file, 'name' => $file, 'alt' => '', 'id_user' => 1, 'deleted' => 0, 'date' => date('Y-m-d H:i:s')));
$idf = $this->db->insert_id();
$this->db->insert('instagram', array('id_file' => $idf, 'link' => $link));
}
$response = $instagram->pagination($response);
}
}
示例2: getTimeline
public function getTimeline($userID = false, $limit = 20)
{
$result = array('result' => array());
$accumulator = $this->debugAccumulatorGroup . '_instagram_timeline';
eZDebug::accumulatorStart($accumulator, $this->debugAccumulatorGroup, 'timeline');
$cacheFileHandler = $this->getCacheFileHandler('timeline', array($userID, $limit));
try {
if ($this->isCacheExpired($cacheFileHandler)) {
$API = new Instagram($this->API['key']);
if ($this->API['token'] !== null) {
$API->setAccessToken($this->API['token']);
}
$items = array();
$response = $API->getUserMedia($userID, $limit);
$items = is_object($response) && isset($response->data) ? $response->data : array();
foreach ($items as $i => $item) {
$items[$i] = self::objectToArray($item);
}
$cacheFileHandler->fileStoreContents($cacheFileHandler->filePath, serialize($items));
} else {
$items = unserialize($cacheFileHandler->fetchContents());
}
eZDebug::accumulatorStop($accumulator);
$result['result'] = $items;
return $result;
} catch (Exception $e) {
eZDebug::accumulatorStop($accumulator);
eZDebug::writeError($e->getMessage(), self::$debugMessagesGroup);
return $result;
}
}
示例3: instagran_feeds_fn
function instagran_feeds_fn($user)
{
//SECRET: f7a23d3958c6421cb59fe1326f7527d8
//CLIENTE-ID: f09df43a57a547deaa1d1873dfa3c7d8
$CLIENT_ID = 'f09df43a57a547deaa1d1873dfa3c7d8';
$CLIENT_SECRET = 'f7a23d3958c6421cb59fe1326f7527d8';
require_once 'instagram.class.php';
// initialize client
try {
$instagram = new Instagram($CLIENT_ID);
// get and display popular images
$user = $instagram->searchUser($user);
// search for user's photos
$media = $instagram->getUserMedia($user->data[0]->id);
if (count($media->data) > 0) {
foreach ($media->data as $item) {
echo '<li>
<a target="_target" href="' . $item->link . '"><img src="' . $item->images->thumbnail->url . '" /></a>';
//echo 'By: <em>' . $item->user->username . '</em> <br/>';
//echo 'Date: ' . date ('d M Y h:i:s', $item->created_time) . '<br/>';
//echo $item->comments->count . ' comment(s). ' .
//$item->likes->count . ' likes. </li>';
}
}
} catch (Exception $e) {
echo 'ERROR: ' . $e->getMessage() . print_r($client);
exit;
}
}
示例4: getInstagramData
function getInstagramData()
{
// Initialize class for public requests
// Setup class
$instagram = new Instagram(array('apiKey' => '73b2123729934af5acbe7d275e382eef', 'apiSecret' => '7d065e9b5bcd47c399139ecb79d2bc92', 'apiCallback' => 'http://misterbrowns.com/'));
$instagram->setAccessToken('509731687.73b2123.3f895a50426f4fed96adbfb6c1c123cc');
$data = $instagram->getUserMedia('52746983', 7);
return $data;
}
示例5: Instagram
*/
require_once '../instagram.class.php';
// initialize class
$instagram = new Instagram(array('apiKey' => 'db64ea18e8394b63b6c4309250b4ea6a', 'apiSecret' => '1e672be29aab4d2e88a79f3dc8919eee', 'apiCallback' => 'http://test.me/php/api/instagram/Instagram-PHP-API-master/example/success.php'));
// receive OAuth code parameter
$code = $_GET['code'];
// check whether the user has granted access
if (isset($code)) {
// receive OAuth token object
$data = $instagram->getOAuthToken($code);
$username = $username = $data->user->username;
$user_id = $data->user->id;
// store user access token
$instagram->setAccessToken($data);
// now you have access to all authenticated user methods
$result = $instagram->getUserMedia();
} else {
// check whether an error occurred
if (isset($_GET['error'])) {
echo 'An error occurred: ' . $_GET['error_description'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Instagram - photo stream</title>
<link href="https://vjs.zencdn.net/4.2/video-js.css" rel="stylesheet">
示例6: Instagram
// Register at http://instagram.com/developer/ and replace client_id with your own
$instagram = new Instagram($client_ID);
// Set keyword for #hashtag
$user = $item_id;
$userid = $instagram->searchUser($username);
$counter = 0;
if (is_array($userid->data)) {
foreach ($userid->data as $key => $value) {
if ($value->username == $username) {
$userid_filter = $userid->data[$counter]->id;
}
$counter++;
}
}
// Get latest photos according to #hashtag keyword
$media = $instagram->getUserMedia($userid_filter, $count);
$count = 0;
$json_format = '{"responseData": {"feed":{"feedUrl": "http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] . '","title":"Instagram / ' . $username . '","link":"http://twitter.com/' . $username . '","author":"","description":"Twitter updates from ' . $username . ' / ' . $username . '.","type":"rss20","entries":[';
if (is_array($media->data)) {
foreach ($media->data as $row) {
if ($count > 0) {
$json_format .= ',';
}
$attached = "";
$attached .= ' <img alt="" src="' . $row->images->standard_resolution->url . '" /> ';
$json_format .= '{"title":' . json_encode($row->caption->text) . ',"link":"' . $row->link . '","author":"' . $row->user->username . '","publishedDate":"' . date("D, d M Y H:i:s O", $row->created_time) . '","contentSnippet":' . json_encode($row->caption->text . $attached) . ',"content":' . json_encode($row->caption->text . $attached) . ',"categories":[]}';
$count++;
}
}
$json_format .= ']}}, "responseDetails": null, "responseStatus": 200}';
header("Content-Type: application/json; charset=UTF-8");
示例7: get_settings
<div class="unit one-of-three">
<div class="phoneSegment">
<div class="phoneNumber">
<?php
echo get_settings('phone_number');
?>
</div>
<a href="https://hbahairdesign.mylocalsalon.com/onlinebooking/" class="bookOnline">Book Online</a>
</div>
<div class="instagramSection">
<?php
$instagram = new Instagram(array('apiKey' => get_option('HBA_INSTA_CLIENT_ID'), 'apiSecret' => get_option('HBA_INSTA_CLIENT_SECRET'), 'apiCallback' => site_url() . '/wp-admin/options-general.php?page=themeOptions.php'));
$instagram->setAccessToken(get_settings('HBA_INSTA_AUTH'));
$user = $instagram->getUser();
$userLike = $instagram->getUserMedia();
?>
<a href="http://instagram.com/<?php
echo $user->data->username;
?>
" class="instagramLink">@hbahair</a>
<a href="http://instagram.com/<?php
echo $user->data->username;
?>
" class="instagramUsLink">Instagram Us!</a>
<div class="instagramPicture">
<img src="<?php
echo $userLike->data[0]->images->standard_resolution->url;
?>