Skip to content

Commit

Permalink
Iconosquare is no longer free, switching to Instagram API instead
Browse files Browse the repository at this point in the history
  • Loading branch information
julienmru committed Jan 31, 2017
1 parent 3e40b90 commit 791b979
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

Importe des images Instagram comme articles SPIP dans la rubrique de votre choix avec le hashtag de votre choix.

Le nom de l’auteur Instagram va dans #TITRE, et la légende de la photo dans #TEXTE.
L’identifiant de l’auteur Instagram va dans #TITRE, et la légende de la photo dans #TEXTE.

Ce plugin utilise les flux RSS de [Iconosquare](http://iconosquare.com/) et l'URL Iconosquare est stockée dans #URL_SITE.
Ce plugin utilise l’API Instagram et lURL du post Instagram est stocké dans #URL_SITE.
1 change: 1 addition & 0 deletions formulaires/configurer_spipagram.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<form action='#ENV{action}' method='post'>
#ACTION_FORMULAIRE{#ENV{action}}
<ul>
[(#SAISIE{input, token, label=<:spipagram:label_token:>, obligatoire=oui, explication=<:spipagram:explication_token:>})]
[(#SAISIE{input, hashtag, label=<:spipagram:label_hashtag:>, obligatoire=oui})]
[(#SAISIE{selecteur_rubrique, rubrique, label=<:spipagram:label_rubrique:>, obligatoire=oui})]
[(#SAISIE{auteurs, auteur, label=<:spipagram:label_auteur:>, obligatoire=oui})]
Expand Down
2 changes: 2 additions & 0 deletions lang/spipagram_en.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
$GLOBALS[$GLOBALS['idx_lang']] = array(

'titre_configurer_spipagram' => 'Configure Spipagram',
'label_token' => 'Instagram Token',
'explication_token' => 'Pleaser enter your token which you can generate either by clicking on "Click here to get your access token" on <a href="http://instagramwordpress.rafsegat.com/docs/get-access-token/">the following page</a> or, for increase security, by using Instagram API.',
'label_hashtag' => 'Hashtag',
'label_rubrique' => 'Target section',
'label_auteur' => 'Articles’ author',
Expand Down
2 changes: 2 additions & 0 deletions lang/spipagram_fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
$GLOBALS[$GLOBALS['idx_lang']] = array(

'titre_configurer_spipagram' => 'Configurer Spipagram',
'label_token' => 'Token Instagram',
'explication_token' => 'Indiquez un token que vous pouvez générer en cliquant sur "Click here to get your access token" sur <a href="http://instagramwordpress.rafsegat.com/docs/get-access-token/">la page suivante</a> ou, pour plus de sécurité, que vous pouvez créer en utilisant l’API Instagram.',
'label_hashtag' => 'Hashtag',
'label_rubrique' => 'Rubrique cible',
'label_auteur' => 'Auteur des articles',
Expand Down
2 changes: 1 addition & 1 deletion paquet.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<paquet
prefix="spipagram"
categorie="multimedia"
version="1.0.1"
version="1.1.0"
etat="stable"
compatibilite="[3.0.0;3.1.*]"
documentation="http://contrib.spip.net/spipagram"
Expand Down
19 changes: 11 additions & 8 deletions spipagram_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ function spipagram_import(){
$_hashtag = ltrim(lire_config('spipagram/config/hashtag'), '#');
$_statut = lire_config('spipagram/config/statut');
$_mots = lire_config('spipagram/config/mots');
$_token = lire_config('spipagram/config/token');

if (!$_rubrique || !$_auteur || !$_hashtag || !$_statut) {
if (!$_rubrique || !$_auteur || !$_hashtag || !$_statut || !$_token) {
spip_log('Plugin non configuré', 'spipagram'._LOG_DEBUG);
return FALSE;
}
Expand All @@ -31,30 +32,32 @@ function spipagram_import(){
include_spip('action/editer_article');
include_spip('action/editer_liens');

$_rss = 'http://iconosquare.com/tagFeed/'.rawurlencode($_hashtag);
$_rss = 'https://websta.me/rss/tag/'.rawurlencode($_hashtag);

include_spip('ecrire/iterateur/data');
include_spip('inc/distant');

$_distant = recuperer_page($_rss, true);

if ($_items = inc_rss_to_array_dist($_distant)) {
if ($_result = json_decode(file_get_contents('https://api.instagram.com/v1/tags/kabardock/media/recent?access_token=245157508.ba4c844.638763c59c9e469fa6800ba03b786e39'))) {

// on règle l'ID auteur pour qu’il puisse créer des article
if (isset($GLOBALS['visiteur_session']) && isset($GLOBALS['visiteur_session']['id_auteur'])) $old_id_auteur = $GLOBALS['visiteur_session']['id_auteur'];
$GLOBALS['visiteur_session']['id_auteur'] = lire_meta('spipagram/config/auteur');

$_items = $_result->data;

foreach($_items as $_item) {

$article = array();
$article['titre'] = $_item['lesauteurs'];
$article['date'] = date('Y-m-d H:i:s', $_item['date']);
$article['texte'] = $_item['titre'];
$article['titre'] = $_item->user->username;
$article['date'] = date('Y-m-d H:i:s', $_item->created_time);
$article['texte'] = $_item->caption->text;
$article['id_rubrique'] = $_rubrique;
$article['url_site'] = $_item['url'];
$article['url_site'] = $_item->link;
$article['statut'] = $_statut;

$article_logo = extraire_attribut(extraire_balise($_item['descriptif'], 'img'), 'src');
$article_logo = $_item->images->standard_resolution->url;

if ($row = sql_fetsel('id_article', 'spip_articles', 'id_rubrique = '.$_rubrique.' AND url_site = '.sql_quote($article['url_site']))) {
$id_article = $row['id_article'];
Expand Down

0 comments on commit 791b979

Please sign in to comment.