sesser / instaphp Goto Github PK
View Code? Open in Web Editor NEWA PHP framework for accessing Instagram's API
Home Page: http://sesser.github.com/Instaphp/
A PHP framework for accessing Instagram's API
Home Page: http://sesser.github.com/Instaphp/
Hi
I'm getting this error:
[User Error] Uncaught GuzzleHttp\Exception\ParseException: Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON
Trace
GuzzleHttp\Message\Response->json()
Response.php:104
Instaphp\Instagram\Response->__construct(HTTP/1.1 404 Not Found Content-Language: en Expires: Sat, 01 Jan 2000 00:00:00 GMT Vary: Cookie, Accept-Language Pragma: no-cache Cache-Control: private, no-cache, no-store, must-revalidate Date: Fri, 01 Jul 2016 08:34:02 GMT X-Frame-Options: SAMEORIGIN Content-Type: text/html Set-Cookie: csrftoken=tB34silDlCK4HPfbyvGUMxV5q6sayjNB; expires=Fri, 30-Jun-2017 08:34:02 GMT; Max-Age=31449600; Path=/ Connection: keep-alive Content-Length: 25167 <script type="text/javascript">window._timings = {"domLoading": Date.now()}</script> <title> Instagram </title> <script type="text/javascript"> WebFontConfig = { custom: { families: ['proxima-nova:n3,n4,n6,n7'], } }; </script> <script src="//instagramstatic-a.akamaihd.net/h1/scripts/webfont.js/c0456c81549b.js" type="text/javascript" async></script> <style type="text/css"> /* @license * MyFonts Webfont Build ID 2164953, 2012-03-23T23:06:30-0400 * * The fonts listed in this notice are subject to the End User License * Agreement(s) entered into by the website owner. All other parties are * explicitly restricted from using the Licensed Webfonts(s). * * You may obtain a valid license at the URLs below. * * * Webfont: Proxima Nova Light by Mark Simonson * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/light/ * Licensed pageviews: unlimited * * Webfont: Proxima Nova Regular by Mark Simonson * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/regular/ * Licensed pageviews: unlimited * * Webfont: Proxima Nova Semibold by Mark Simonson * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/semibold/ * Licensed pageviews: unlimited * * Webfont: Proxima Nova Bold Italic by Mark Simonson * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/bold-it/ * Licensed pageviews: unlimited * * Webfont: Proxima Nova Bold by Mark Simonson * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/bold/ * Licensed pageviews: unlimited * * Webfont: Proxima Nova Italic by Mark Simonson * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/regular-it/ * Licensed pageviews: unlimited * * * License: http://www.myfonts.com/viewlicense?type=web&buildid=2164953 * Webfonts copyright: Copyright (c) Mark Simonson, 2005. All rights reserved. * * (c) 2012 Bitstream Inc / @font-face { font-family: 'proxima-nova'; src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.eot/115b1f7f9c04.eot'); src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.eot/115b1f7f9c04.eot?#iefix') format("embedded-opentype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.woff/618250d25a4d.woff') format("woff"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.ttf/646346e03084.ttf') format("truetype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.svg/e55a9d6051e8.svg#ProximaNovaBold') format("svg"); font-weight: bold; font-style: normal; } @font-face { font-family: 'proxima-nova'; src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.eot/1cbb869da891.eot'); src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.eot/1cbb869da891.eot?#iefix') format("embedded-opentype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.woff/b1cf049474c9.woff') format("woff"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.ttf/3adb020ceae3.ttf') format("truetype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.svg/29948a2d3c58.svg#ProximaNovaBoldItalic') format("svg"); font-weight: bold; font-style: italic; } @font-face { font-family: 'proxima-nova'; src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.eot/12af77715cee.eot'); src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.eot/12af77715cee.eot?#iefix') format("embedded-opentype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.woff/a9a9773b8e29.woff') format("woff"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.ttf/99e19808976a.ttf') format("truetype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.svg/c33d2fd56309.svg#ProximaNovaRegular') format("svg"); font-weight: normal; font-style: normal; } @font-face { font-family: 'proxima-nova'; src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.eot/1bbbd1312b0d.eot'); src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.eot/1bbbd1312b0d.eot?#iefix') format("embedded-opentype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.woff/9e306befca91.woff') format("woff"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.ttf/4a8663684135.ttf') format("truetype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.svg/876278d4b189.svg#ProximaNovaRegularItalic') format("svg"); font-weight: normal; font-style: italic; } @font-face { font-family: 'proxima-nova'; src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.eot/5016edf79e1d.eot'); src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.eot/5016edf79e1d.eot?#iefix') format("embedded-opentype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.woff/615c1b06d8fa.woff') format("woff"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.ttf/2973bd483f7a.ttf') format("truetype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.svg/868597833e49.svg#ProximaNovaSemibold') format("svg"); font-weight: 600; font-style: normal; } </style> <style type="text/css"> @font-face { font-family: 'proxima-nova'; src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.eot/63c84728610f.eot'); src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.eot/63c84728610f.eot?#iefix') format("embedded-opentype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.woff/66bbe029f180.woff') format("woff"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.ttf/eb408516399b.ttf') format("truetype"), url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.svg/858f6a9b7ef3.svg#ProximaNovaLight') format("svg"); font-weight: 300; font-style: normal; } </style> <script type="text/javascript"> (function() { var docElement = document.documentElement; var classRE = new RegExp('(^|\s)no-js(\s|$)'); var className = docElement.className; docElement.className = className.replace(classRE, '$1js$2'); })(); </script> <style type="text/css">/ @generated / / DO NOT CHANGE THIS FILE. INSTEAD, MODIFY 'distillery/templates/main.css' / / css shared between /about and /developer / / run build/scripts/css_transform_distillery.sh
if you change this file / body { -webkit-font-smoothing: antialiased; background-color: #fafafa; font-family: 'proxima-nova', 'Helvetica Neue', Arial, Helvetica, sans-serif; margin-bottom: 60px; margin: 0; } a { text-decoration: none; } /*...)
Instagram.php:331
This code:
<?php
//-- Include our library
include_once 'instaphp/instaphp.php';
//-- Get an instance of the Instaphp object
$api = Instaphp\Instaphp::Instance();
//-- Get the response for Popular media
$response = $api->Media->Popular();
//-- Check if an error was returned from the API
if (empty($response->error))
{
foreach ($response->data as $item)
printf('<img src="%s" width="%d" height="%d" alt="%s">', $item->images->thumbnail->url, $item->images->thumbnail->width, $item->images->thumbnail->height, empty($item->caption->text) ? 'Untitled':$item->caption->text);
} else {
print_r($response->error);
}
?>
return below array:
Instaphp\Error Object ( [type] => cURLResponseError [code] => 0 [message] => Unknown error ocurred making this request [url] => https://api.instagram.com/v1/media/popular?client_id=b5301a429b184b10995844be4d099849 )
What is it? What I should do?
Line 36 of instaphp.php requires cache/file.php, but the cache directory was removed in 525b0c35e3e4a0eca0479eddd9f8982e3977b69a.
Are you planning to support the new API? https://developers.facebook.com/docs/instagram-basic-display-api/reference/media
Hi guys,
question: do i need all the content of the created "vendor" folder? With 8MB it´s very big.. because i´m using your project to develope a wordpress plugin i have to optimize as much as possible to keep the plugin-file small.
Content of vendor folder: bin (folder), composer (folder), guzzlehttp (folder), monolog (folder), phpunit (folder), psr (folder), react (folder), symfony (folder), autoload.php
.. do i need all of this for your plugin in live-version?
Thank you very much!
Greetings
Saying I have pictures tagged by 'vihdk', 'e2015' and 'intro', how do I get pictures from instagram, which shares those tags? Is that even possible?
Warning: Creating default object from empty value in Response.php on line 186
I have absolutely no idea if this is the best way to solve it but in Response.php:
add this to the constructor
+
112: $this->auth = new \stdClass();
This eliminates the error.
I´m trying this call
$code = $_REQUEST['code'];
$inst1 = Instaphp::Instance();
$miuser = new Users();
$respuesta = $miuser->Authenticate($code);
$access_token = $respuesta->auth->access_token;
$user_id = $respuesta->auth->user->id;
$arr = array("access_token" => $access_token);
$recent = $miuser->Recent($user_id, $arr);
but the object $recent myself that I returned is null
doing a trace on the file "response.php" i can print the url value and this has the correct structure on $opts[CURLOPT_URL]: https://api.instagram.com/v1/users/83272/media/recent/?client_id=MYCLIENTID&access_token=MYACCESTOKEN
But when I go to print out the contents of the variable $res I see is empty (after this line if (false !== ($res = curl_exec($this->ch))) {)
What am I doing wrong?
Hello again!
I write because I'm having problems with login to instagram (with the iframe method). I have it really the problem with Safari. There seems to be a problem with PHP and this browser session when they are created from an iframe. I've seen the same problem happens in instaview.me. The problem grew as devices such as iPhone and iPad using Safari. (To see exactly what I'm talking about you can try to validate you in your application through your iPhone or through Safari for PC, cheesy the second time you try to validate you can read the session).
I have been looking on the internet about this issue but have not found any solution.
Can you think of a solution?
I just upgraded to the latest version of instaphp and it looks like guzzlehttp/log-subscriber is not compatible with Guzzle 6
See the note from https://github.com/guzzle/log-subscriber
[DEPRECATED AND ABANDONED] Logs HTTP requests and Responses as they are sent over the wire. Not used in Guzzle 6.
@sesser Could you revert the composer change which updated the Guzzle requirement to 6?
Hi
Is there any reason to get stuck with 1.8.*
version? I get a conflict because other library needs at least 1.12
version. Or maybe instead 1.8.*
you meant ~1.8
?
Could we change monolog versioning for ~1.8
, please?
Hi, I got this error when using instaphp through hautelook InstagramBundle
An exception has been thrown during the rendering of a template ("The response from Instagram cannot be parsed.")
[2/2] Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("The response from Instagram cannot be parsed.") in index.html.twig at line 36. +
[1/2] InvalidInstagramResponseException: The response from Instagram cannot be parsed. -
in C:\xampp\htdocs\Symfony\vendor\hautelook\instagram-bundle\Hautelook\InstagramBundle\Instagram\Manager.php at line 58 -
}
if (empty($data) || !is_array($data)) {
throw new InvalidInstagramResponseException();
}
$rawResponseData = array_slice($data, 0, min($numRecent, self::MAX_RECENT));
Can you please tell me what I did wrong ?
I get this error on trying to instantiate the instaphp class. I am not using composer; Just downloaded the source and included the php file.
Could you upload a file type to learn how to use such methods?
For example, something simple, to authenticate a user ... recover your photos ... thank you very much in advance
I have
Fatal error: Class 'Instaphp' not found in \profile\index.php on line 18
File index.php: ('Instaphp' folder at 'profile' folder)
<?php
/* gentlemen, start your sessions */
session_start();
$access_token = null;
/* check to see if we have an access token stored in the session */
if (isset($_SESSION['access_token']) && !empty($_SESSION['access_token']))
$access_token = $_SESSION["access_token"];
/*
Get our Instaphp instance passing the $access_token
Once the access_token is set, there's no need to pass
it along in subsequent api calls as it is automatically
passed.
*/
$api = Instaphp::Instance($access_token);
/* if the access_token is empty, do your authentication here */
if (empty($access_token)) {
if (isset($_REQUEST["code"])) {
$res = $api->Users->Authenticate($_REQUEST["code"]);
if (empty($res->error) && !empty($res->auth->access_token)) {
$_SESSION["access_token"] = $res->auth->access_token;
/* store the user object in the session as well... don't forget to serialize */
$_SESSION["auth_user"] = @serialize($res->auth->user);
}
}
}
/*
no need to create any new Instaphp objects.
They're already setup in the main Instaphp object.
*/
$recent = $api->Users->Recent("self");
/* Your data should be here */
print_r($recent->data);?>
Fatal error: Uncaught exception 'ReflectionException' with message 'Class Instaphp\Instagram\Media does not exist' in /usr/local/www/apache24/data/Instaphp/src/Instaphp/Instaphp.php:111 Stack trace: #0 /usr/local/www/apache24/data/Instaphp/src/Instaphp/Instaphp.php(111): ReflectionClass->__construct('Instaphp\Instag...') #1 /usr/local/www/apache24/data/success.php(12): Instaphp\Instaphp->__get('Media') #2 {main} thrown in /usr/local/www/apache24/data/Instaphp/src/Instaphp/Instaphp.php on line 111
Do you plan support Guzzle 6.*?
The support of embedding (/oembed
) would be a good PR ?
Please update Guzzle from 4 to 5. Here is instruction: https://github.com/guzzle/guzzle/blob/master/UPGRADING.md
I'm not really sure but there is no conflicts with current code.
Whether or not log_enabled is set to true or false doesn't seem to impact logging.
Looking at the source shows that monolog is always instantiated.
https://github.com/sesser/Instaphp/blob/master/src/Instaphp/Instagram/Instagram.php#L86-L87
Did I miss something?
did the composer install
included the file to the autoload.php
getting this error when attempting your example:
<br />
<b>Fatal error</b>: Uncaught Instaphp\Exceptions\HttpException: Bad Request in /var/www/html/vendor/instaphp/instaphp/src/Instaphp/Instagram/Instagram.php:364
Stack trace:
#0 /var/www/html/vendor/instaphp/instaphp/src/Instaphp/Instagram/Instagram.php(201): Instaphp\Instagram\Instagram->parseResponse(Object(GuzzleHttp\Message\Response))
#1 /var/www/html/vendor/instaphp/instaphp/src/Instaphp/Instagram/Media.php(55): Instaphp\Instagram\Instagram->get('/media/popular', Array)
#2 /var/www/html/testy.php(12): Instaphp\Instagram\Media->Popular(Array)
#3 {main}
thrown in <b>/var/www/html/vendor/instaphp/instaphp/src/Instaphp/Instagram/Instagram.php</b> on line <b>364</b><br />
Using signed headers, we can call more times certains POST endpoints. For example, POST /users/user-id/relationships
endpoint without signing the limit is 20 calls per hour, with signature, we can do 60 (https://instagram.com/developer/limits/). To sign the header, here is the doc: https://instagram.com/developer/restrict-api-requests/#enforce-signed-header.
My implementation proposal:
enforce_signed_header
, false
by default.ips
parameter, 127.0.0.1
by default.enforce_signed_header
is true
, we add a header Insta-X-Forwarded-For
to request Guzzle having as value <ip_information>|<signature>
as described in the documentation page.It can take some hours to figure this out instead ;)
In the response object the pagination data is filled correctly (next_url & next_max_id) when the user has more then 20 recent photos.
Is there a way to reach the next photos? I couldn't figure out how it works.
thanks.
Hello again!!
I need to logout the connected user of Instagram.
How can I do this?
In instaphp I can´t see any function or method, and I can´t see it in the official api instagram too.
Thank you very much for your support!!
Fatal error: Uncaught GuzzleHttp\Ring\Exception\ConnectException: cURL error 28: Resolving timed out after 2511 milliseconds in /var/www/html/tyn/Instaphp/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php:126 Stack trace: #0 /var/www/html/tyn/Instaphp/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php(91): GuzzleHttp\Ring\Client\CurlFactory::createErrorResponse(Array, Array, Array) #1 /var/www/html/tyn/Instaphp/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php(96): GuzzleHttp\Ring\Client\CurlFactory::createResponse(Array, Array, Array, Array, Resource id #4) #2 /var/www/html/tyn/Instaphp/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php(68): GuzzleHttp\Ring\Client\CurlHandler->_invokeAsArray(Array) #3 /var/www/html/tyn/Instaphp/vendor/guzzlehttp/ringphp/src/Client/Middleware.php(54): GuzzleHttp\Ring\Client\CurlHandler->__invoke(Array) #4 /var/www/html/tyn/Instaphp/vendor/guzzlehttp/ringphp/src/Client/Middleware.php(30): GuzzleHttp\Ring\Client\Middleware::GuzzleHttp\Ring\Client{closure}(Array) #5 /var/www/html/ in /var/www/html/tyn/Instaphp/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 49
Hello I got this error when I execute the demo in the readme:
...
array(3) {
["code"]=>
int(403)
["error_type"]=>
string(23) "OAuthForbiddenException"
["error_message"]=>
string(56) "Invalid signed-request: Missing required parameter 'sig'"
}
...
Hello, same dependency hell again with Guzzle 6 :)
I thought you might be interested in some simple functionality I added to the Symfony version of Instaphp
ollietb/OhInstagramBundle@95aca8b
Can be used like this:
$response = $this->api->Tags->Recent($tag, $options);
do {
$pages[] = $response->data;
} while($response = $response->getNextPage());
It will get every page of results and put each into the $pages array
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.