本文整理汇总了PHP中Instagram类的典型用法代码示例。如果您正苦于以下问题:PHP Instagram类的具体用法?PHP Instagram怎么用?PHP Instagram使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Instagram类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: InstaTagMedia
public function InstaTagMedia($tag = false, $num = false, $shuffle = true)
{
$instagram = new Instagram(array('apiKey' => $this->InstagramApiKey, 'apiSecret' => $this->InstagramApiSecret, 'apiCallback' => $this->InstagramApiCallback));
$media = false;
$output = false;
$out = array();
if (!$tag) {
$tag = $this->InstagramSearchTerm;
}
if (!$num) {
$num = $this->InstagramItemsCount;
}
try {
$media = $instagram->getTagMedia($tag, 50);
} catch (Exception $e) {
SS_Log::log(new Exception(print_r($e, true)), SS_Log::ERR);
}
if (is_object($media) && isset($media->data)) {
foreach ($media->data as $data) {
if (is_object($data)) {
$item = array('caption' => $data->caption ? $data->caption->text : "", 'thumb' => $data->images->thumbnail->url, 'image' => $data->images->standard_resolution->url, 'username' => $data->user->username);
array_push($out, $item);
}
}
if ($shuffle) {
shuffle($out);
}
$output = ArrayList::create($out);
$output = $output->limit($num);
}
return $output;
}
示例3: nextend_api_auth_flow
function nextend_api_auth_flow()
{
$api_key = NextendRequest::getVar('api_key');
$api_secret = NextendRequest::getVar('api_secret');
$redirect_uri = NextendRequest::getVar('redirect_uri');
if (session_id() == "") {
@session_start();
}
if (!$api_key || !$api_secret || !$redirect_uri) {
$api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
$api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
$redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null;
} else {
$_SESSION['api_key'] = $api_key;
$_SESSION['api_secret'] = $api_secret;
$_SESSION['redirect_uri'] = $redirect_uri;
}
if ($api_key && $api_secret) {
require_once dirname(__FILE__) . "/api/Instagram.php";
$config = array('client_id' => $api_key, 'client_secret' => $api_secret, 'redirect_uri' => $redirect_uri, 'grant_type' => 'authorization_code');
$instagram = new Instagram($config);
$accessCode = $instagram->getAccessCode();
if ($accessCode === null) {
$instagram->openAuthorizationUrl();
} else {
$accessToken = $instagram->getAccessToken();
unset($_SESSION['api_key']);
unset($_SESSION['api_secret']);
unset($_SESSION['redirect_uri']);
echo '<script type="text/javascript">';
echo 'window.opener.setToken("' . $accessToken . '");';
echo '</script>';
}
}
}
示例4: 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;
}
}
示例5: smamo_instagram
function smamo_instagram()
{
// Klargør svar
$response = array();
$num = isset($_POST['num']) ? 4 * wp_strip_all_tags($_POST['num']) : 4;
// vi skal bruge et hashtag, ellers die();
if (!isset($_POST['hash'])) {
$response['code'] = '400';
$response['error'] = 'No hashtag received';
wp_die(json_encode($response));
}
// Indstil $tag
$tag = wp_strip_all_tags($_POST['hash']);
// Inkluder instagram class
require get_template_directory() . '/functions/instagram/instagram.class.php';
// Opret ny instance
$instagram = new Instagram(array('apiKey' => 'dd36cc7a7be445c8a00d9f383e49f8c8', 'apiSecret' => 'e750735ffba74f8a8ed753a33c7351da', 'apiCallback' => 'http://faaborg-gym.dk'));
$response['images'] = array();
$inst_obj = $instagram->getTagMedia($tag, $num);
$next_page = $instagram->pagination($inst_obj);
$response['next'] = $next_page;
foreach ($inst_obj->data as $key => $val) {
$response['images'][] = $val;
}
wp_die(json_encode($response));
}
示例6: onNextendInstagram
function onNextendInstagram(&$instagram)
{
$config = new NextendData();
$config->loadJson(NextendSmartSliderStorage::get(self::$_group));
require_once dirname(__FILE__) . "/api/Instagram.php";
$c = array('client_id' => $config->get('apikey', ''), 'client_secret' => $config->get('apisecret', ''), 'redirect_uri' => '', 'grant_type' => 'authorization_code');
$instagram = new Instagram($c);
$instagram->setAccessToken($config->get('token', ''));
}
示例7: 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;
}
示例8: getAllFeeds
public static function getAllFeeds()
{
$fb = new FacebookUtils();
$fbFeed = $fb->getFeed();
$ig = new Instagram();
$igFeed = $ig->user(2256663036)->count(10)->getPosts();
$feed = array_merge($fbFeed, $igFeed);
shuffle($feed);
return $feed;
}
示例9: execute
/**
*
* Execute the Request
*
* @return object Response Data
* @throws InstagramException
*/
public function execute()
{
$response = parent::execute();
$this->response = $response;
if ($this->throwExceptionIfResponseNotOk() && !$response->isOK()) {
throw new InstagramException(sprintf("Instagram Request Failed! [%s] [%s]", $this->getEndpoint(), $response->getCode()));
}
$this->instagram->setCookies(array_merge($this->instagram->getCookies(), $response->getCookies()));
return $this->parseResponse($response);
}
示例10: feed
public function feed()
{
Phalanx::loadClasses('SocialNetwork');
$token = SocialNetwork::get_access_token(1, INSTAGRAM);
$token = json_decode($token);
$instagram = new Instagram($this->config);
$instagram->setAccessToken($token->access_token);
$popular = $instagram->getUserFeed();
$response = json_decode($popular, true);
foreach ($response['data'] as $each) {
echo "<img src='{$each['images']['thumbnail']['url']}'>";
}
}
示例11: Instagram
<?php
##########################################################
## ##
## Desenvolvido por Rodrigo Passos ##
## http://www.rodrigop.com.br ##
## contato@rodrigop.com.br ##
## ##
## Sinta-se livre para alterar o que quiser :) ##
## ##
##########################################################
require_once "class.php";
if ($_REQUEST["url"]) {
$Instagram = new Instagram();
if ($_REQUEST["action"] == "1") {
echo $Instagram->loadMore($_REQUEST["url"]);
} else {
if ($_REQUEST["action"] == "2") {
echo $Instagram->getUrlMore($_REQUEST["url"]);
}
}
}
示例12: array
* URI callback that you must set up with Instagram as the return address
* for your application on their developers section:
* http://instagr.am/developer/
*
*
* If you have any question, check http://mauriciocuenca.com/ for the
* latest updates
**/
require_once 'Instagram.php';
/**
* Configuration params, make sure to write exactly the ones
* instagram provide you at http://instagr.am/developer/
*/
$config = array('client_id' => 'e1d602f8517645749de38593dbf9ad25', 'client_secret' => '63dbfae2a6444956802e269384fc05cc', 'grant_type' => 'authorization_code', 'redirect_uri' => 'http://www.HoopsMap.com/instagram/');
/**
* This is how a wrong response looks like
* array(1) { ["InstagramOAuthToken"]=> string(89) "{"code": 400, "error_type": "OAuthException", "error_message": "No matching code found."}" }
*/
session_start();
/**
if (isset($_SESSION['InstagramAccessToken']) && !empty($_SESSION['InstagramAccessToken'])) {
header('Location: index.php');
die();
}
**/
// Instantiate the API handler object
$instagram = new Instagram($config);
$instagram->openAuthorizationUrl();
?>
示例13: Instagram
<?php
require '../src/Instagram.php';
include 'data.php';
$i = new Instagram($username, $password, $proxy, $debug);
try {
$i->login();
} catch (InstagramException $e) {
$e->getMessage();
exit;
}
try {
$i->uploadPhoto($photo, $caption);
} catch (Exception $e) {
echo $e->getMessage();
}
示例14: session_start
<?php
session_start();
if (!isset($_SESSION['AccessToken'])) {
header('Location: redirect.php?op=getauth');
die;
}
require_once 'Class.Instagram.php';
$instgram = new Instagram();
$followingdata = json_decode($instgram->getFollowing(20));
/* echo "<pre>";
print_r($followingdata);
echo "</pre>"; */
include_once 'header.php';
include_once 'leftmenu.php';
?>
<div id="content">
<div id="content_top"></div>
<div id="content_main">
<?php
foreach ($followingdata->data as $feeddata) {
?>
<h2> </h2>
<p> </p>
<h3><img src="<?php
echo $feeddata->profile_picture;
?>
" width="60" height="60" caption="Profile Image"> <?php
echo $feeddata->username;
?>
</h3>
示例15: Instagram
<?php
/**
* Instagram PHP API
*
* @link https://github.com/cosenary/Instagram-PHP-API
* @author Christian Metz
* @since 01.10.2013
*/
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'];
}
}
?>