Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding license and README file

  • Loading branch information...
commit 372f7ea1a427ee78338620d5008c7d4a6fb7b207 1 parent 487890a
@macuenca authored
Showing with 54 additions and 1 deletion.
  1. +25 −1 Instagram.php
  2. +11 −0 README
  3. +18 −0 example.php
View
26 Instagram.php
@@ -1,5 +1,21 @@
<?php
-
+/**
+ * Instagram PHP implementation API
+ * URLs: http://www.mauriciocuenca.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
require_once 'Zend/Http/Client.php';
class Instagram {
@@ -58,6 +74,10 @@ class Instagram {
*/
protected $_httpClient = null;
+ /**
+ * Constructor needs to receive the config as an array
+ * @param mixed $config
+ */
public function __construct($config = null) {
$this->_config = $config;
if (empty($config)) {
@@ -65,6 +85,10 @@ public function __construct($config = null) {
}
}
+ /**
+ * The init method is triggered on every call to retrieve the
+ * access token in case is not in the current instance.
+ */
protected function _init() {
// Requests the OAuth token if none passed
if ($this->_accessToken == null) {
View
11 README
@@ -0,0 +1,11 @@
+## This is a very simple instagram API implementation in PHP.
+This first version depends on the Zend_Http_Client component from Zend Framework[1]. The code was made in such a way that it is HTTP client agnostic, but right now I'm working on an specific CURL-based client implementation so we don't depend on Zend Framework.
+
+You don't need to download the whole Zend Framework stack to make this implementation work. Just make sure you have the HTTP Client[2] and everything under the 'Client' tree[3], anyway, the minimal version is very small and you can downloaded right from here[4]
+
+If you take a look at the code, you'll notice that every method is mostly similar, with the exception of the endpoint, the number of params passed and the HTTP method performed. Yes, I did a first version of the API without a single one but a __call() method which, based on the endpoints mapping, created the right request and sent it to the server. After using it for a while, I just thought it was too simple, error prone and didn't help the auto-complete feature when you use a fancy IDE. This code is open source, so any ideas or suggestions will be welcomed, hope you use it and enjoy it!
+
+[1] http://framework.zend.com/
+[2] http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Http/Client.php
+[3] http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Http/Client/
+[4] http://framework.zend.com/download/latest
View
18 example.php
@@ -1,5 +1,23 @@
<?php
/**
+ * Instagram PHP implementation API
+ * URLs: http://www.mauriciocuenca.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
* Instagram PHP API example usage.
* This script must be the one receiving the response from
* instagram's servers after requesting an access token.
Please sign in to comment.
Something went wrong with that request. Please try again.