https://www.drupal.org/sandbox/chriscollins405/2836169

git clone --branch 7.x-1.x https://git.drupal.org/sandbox/chriscollins405/2836169.git instagram_scrape_feed
cd instagram_scrape_feed

This is my third module. I have been through this process before, but as my last module didnt quite have enough lines in it, I was able to make it a full project, but not have the permission to add my own full projects.
https://www.drupal.org/project/zurb_responsive_tables
https://www.drupal.org/sandbox/chriscollins405/2747947

Instagram Scrape Feed provides an Instagram feed in a block that does not require authentication, access tokens or API keys. It simply scrapes a public Instagram profile and returns up to 12 posts.

Why?
We build loads of sites, and getting an Instagram feed set up is always a pain. You have to get access tokens, or API keys, and get the clients login details so you can do this. We built this module to create a really easy and simple way to display a feed in a block.

How does it work?
The module will scrape a public Instagram profile page, and find the 12 latest posts. It will return the standard square image, "like" count, "comment" count and the post caption. We got the basic idea from https://gist.github.com/cosmocatalano/4544576 and went our own way with it.

Configuration
You can control the username, number of posts to display, number of columns to show, and trim the caption length.

How to use (Very Easy)
Simply...

  1. Place the module in your sites directory and enable as normal.
  2. Configure the block in Structure > Blocks.
  3. Enter the Instagram username you wish to display.
  4. Configure the number of posts and number of columns to fit your theme and style.
  5. Done! :-)

Whats the catch?
This module makes no attempt to store the Instagram post data, and does not integrate with Entity API. If you need that functionality, check out the other options out there. This is just a dirty, quick, easy alternative for people who want to get a feed up and running in a few clicks.
The Instagram profile you want to scrape must be set as public.

Screenshots
Instagram scrape
Instagram scrape

Comments

Collins405 created an issue. See original summary.

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

Collins405’s picture

Issue summary: View changes
Collins405’s picture

Issue summary: View changes
visabhishek’s picture

Issue summary: View changes
visabhishek’s picture

Status: Active » Needs work
Issue tags: +PAreview: security

Automated Review

Please fix the issue reported on https://pareview.sh/node/434

Manual Review

Individual user account
[Yes: Follows] the guidelines for individual user accounts.
No duplication
[No: Causes] module duplication and/or fragmentation.
Master Branch
[Yes: Follows ] the guidelines for master branch.
Licensing
[Yes: Follows] the licensing requirements.
3rd party assets/code
[Yes: Follows ] the guidelines for 3rd party assets/code.
README.txt/README.md
[No: Does not follow] the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
[Yes: Follows] the guidelines for project length and complexity.
Secure code
No: List of security issues identified.]
  1. URLs must be checked with check_url() and You need to sanitize user provided input before printing into #markup.
  2. Example Code :

    		  $posturl = 'https://www.instagram.com/p/' . $posts[$i]['code'];
    		  $block['content']['#markup'] .= '<div class="instagram-row column-' . $column_count . ' ' . $posttype . '">';
    		  $block['content']['#markup'] .= '<a href="' . $posturl . '" target="blank"><img src="' . $imgurl . '" alt="' . $caption . '" /></a>';
    		  $block['content']['#markup'] .= '<span class="stats"><span class="likes"><span>likes</span>' . $likes . '</span><span class="comments"><span>comments</span>' . $comments . '</span></span>';
    		  if ($max_length != 0) {
    		    $block['content']['#markup'] .= '<span class="caption">' . $caption . '</span>';
    		  }
    		  $block['content']['#markup'] .= '</div>';
    
  3. Add t() for user facing text.
  4. Example

    $block['content']['#markup'] .= 'Set a user name to view the posts';
    
Coding style & Drupal API usage
[List of identified issues in no particular order. Use (*) and (+) to indicate an issue importance. Replace the text below by the issues themselves:
  1. suggestion : Please use l() instead <a> tag and theme() instead of writing html tags.
  2. Example Code :

    		  $posturl = 'https://www.instagram.com/p/' . $posts[$i]['code'];
    		  $block['content']['#markup'] .= '<div class="instagram-row column-' . $column_count . ' ' . $posttype . '">';
    		  $block['content']['#markup'] .= '<a href="' . $posturl . '" target="blank"><img src="' . $imgurl . '" alt="' . $caption . '" /></a>';
    		  $block['content']['#markup'] .= '<span class="stats"><span class="likes"><span>likes</span>' . $likes . '</span><span class="comments"><span>comments</span>' . $comments . '</span></span>';
    		  if ($max_length != 0) {
    		    $block['content']['#markup'] .= '<span class="caption">' . $caption . '</span>';
    		  }
    		  $block['content']['#markup'] .= '</div>';
    

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

sandip27’s picture

Hello Collins405,

I have had reviewed few files off of module and below are my findings. Please take care of those.

1. In File, instagram_scrape.install, should have "@file" in doc comments.

/**
 * Implements hook_uninstall().
 */

2. Remove the white spaces off of file at end of file.

3. Maintain no. of characters in each line.

4. In File, instagram_scrape.module, file doc comments are missing.

5. In the same file, function doc comments seems are also missing. Please take care of it.

6. Use "/**" for function comments

There are a lots spacing and lines issues, please take care of those.

Thanks

Collins405’s picture

Status: Needs work » Needs review

Hi sandip27 and visabhishek,

Thank you for taking the time to review this module.

I have fixed the following problems...

  1. Fixed all problems reported on https://pareview.sh/node/434
  2. Added check_url to the $posturl variable
  3. Added check_plain to all user inputted data
  4. Added @file statements
  5. Added a fallback for when the instagram user name can not be found or is set to private

visabhishek, you mentioned using l() instead of<a>, but I cant find a good example of doing this with an image as the anchor content.

Is this correct?

l('<img src="' . $imgurl . '" alt="' . $caption . '" />', $posturl, array('attributes' => array('target' => '_blank')));

I have tried the above, but as l() only accepts text, and uses check_plain, as I pass an <img> into it, it returns it as plain text which doesnt work.

Collins405’s picture

Issue summary: View changes
Collins405’s picture

As mentioned above, I have decided to ignore the suggestion to use l() instead of <a>, due to the way the Instagram image needs to be formatted.

Module is now ready for review again.

Collins405’s picture

I'd love someone to RBTC this project if they have the time! Thanks.

jeetendrakumar’s picture

@Collins405

Please use following code instead of <a>
$block['content']['#markup'] .= l('<img src="' . $imgurl . '" alt="' . $caption . '" />', $posturl, array('attributes' => array('target' => '_blank'), 'html' => true));

VoidE’s picture

I noticed you forgot some spaces after colons in your css files. (Lines 9, 96, 97, 98, 114)
For Example:

.instagram-row {
  float: left;
  position: relative;
  overflow: hidden;
  margin:0 1% -7px 1%;
}

Also I'm wondering why you defined the function `scrape_insta` inside the function `instagram_scrape_block_view`. I don't know if it's wrong, but I'm used to define functions all on the same level. Just wondering.

VoidE’s picture

Status: Needs review » Needs work
kumar_kundan’s picture

I have used this module. It is working fine for me. Code/readme all looks good to me.

+1

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

Collins405’s picture

I will fix the code review issues asap, and also the link.