PHP - Instagram Real-time Api With Php
Hi guys, got some questions about the Instagram real-time api. first let me tell you what I want to do. I'd like to run a daemon process with a socket connection or something of the like to the Instagram API to get a constant feed of photos with a certain tag. We estimate it to be a large amount of data at a particular time (thus why we want to go Real-time). This process will parse the feed and store it into a mongodb database.
Secondly, for the front end, I'd like to display all new, live photos in real-time, possible with ajax or some form of checking on a set interval. Problem being, I can't find anyone doing this with php. All of the resources I have seen use Node.js and Tornado. Has anyone done this with PHP or know of a good Real-time API demonstration/tutorial to get me started? Here's the documentation... http://instagr.am/developer/realtime/ any help would be greatly appreciated! thanks! Similar TutorialsOk so I have a question. is it possible to make a form submit to a DB in real time without the need for a submit button ? if so could you drop a hint to what it would be caled or a tut / reference to it ? I wrote a short script that takes a list of keywords and does a Google search to find how often they are used in the title of a page. However, I cannot get it to echo the results in real time. On one server I use it works fine. On the other it runs the entire list and then outputs everything in the end. The problem is sometimes this takes several minutes and therefore it times out after not receiving a response. Any suggestions? Thanks in advance. <?php $file = file('words.txt'); $results = ''; foreach ($file as $line) { $data = file_get_contents("http://www.google.com/search?hl=en&q=allintitle%3A%22" . urlencode($line) . "%22&btnG=Google+Search"); preg_match('/of about <b>([0-9,]*)?<\/b>/si', $data, $number); $results .= $line . ";" . $number[1]; echo $results . "</br>"; $results = ""; sleep(2); } ?> Hi, i am thinking of creating a text based game mmorpg using php/mysql etc... I know that a lot of these types of games use a tick based system, but i want it to be realtime, the only game i cna find that uses this is Torn, does anyone know how they make it realtime? I know that ticks can be controlled by cronjobs, but how about realtime? The problem is that the game might involve the player building a house, in a tick based system it could be easy to manage by saying the house will take 3 ticks to complete, but i want the house to be like in 10 minutes of 32 minutes, how can i do this. Someone said to check whenever the player next logs in to check if the house has finished and then say it has been built, but seeing as it is an mmorpg it could affect everyones gameplay, not just the person building it, so this will not work. Thanks and sorry if this is a bit confusing. Hi. How to implement twitter like real-time sharing system? So that is like, if my friend(following person) write a message, it also appear on my wall(page). 1. Is it hard? 2. What language used for it? PHP? 3. Is there any source about it? Thanks. I'm working on a chat using basic textarea input, post, but the problem that I'm facing is, if a person doesn't send something, then the output is not updated eg. other messages from other users updating in real time.
How is that achieved when you see new database entries pop up live, milliseconds after they are entered?
Do I set a constant refresh rate of some sort?
How do you update a section of a webpage without "refreshing" the entire page like the POST method?
This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=322054.0 I'm not looking for code, mostly just some direction, but I'm sure I'll be back as I try to shape the code. Also, I know very little about coding jQuery, Ajax, etc. Here is what I'm looking for: Basketball coach enters a Page that only he (or admin) can see. (I have that part figured out.) Once there, he has a form to fill out with a player's name and other information. I'd rather there not be 12 rows of empty cells. (Coaches will view that as work) I'd rather not have the Page reload on each "Add", but that would be the lesser of two evils. Is there a way to keep a persistent connection so when a coach hits Add, the player gets added to the database, a new empty form shows up, and the player's information shows up below on a roster? I am trying to use Cosenary's Instagram Class which is located at.. https://github.com/c...stagram-PHP-API Specifically, I am trying to do Pagination with a Tag Search. I want it to loop the process until it reach's yesterday's posts. I will run this script daily. <?php /** * Instagram PHP API * * @link https://github.com/cosenary/Instagram-PHP-API * @author Christian Metz * @since 01.10.2013 */ require '../dbinclude.php'; require 'Instagram.php'; use MetzWeb\Instagram\Instagram; // initialize class $instagram = new Instagram(array( 'apiKey' => '***************', 'apiSecret' => '***************', 'apiCallback' => '*************' // must point to success.php )); ?> <?php $i = 0; $imagecount = 0; do { $i++; echo "Pagination restart"; $photos = $instagram->getTagMedia('kittens'); $result = $instagram->pagination($photos); foreach($result->data as $post) { $image = mysqli_real_escape_string($toolconn, $post->images->low_resolution->url); $caption = mysqli_real_escape_string($toolconn, $post->caption->text); $author = mysqli_real_escape_string($toolconn, $post->user->username); $created = mysqli_real_escape_string($toolconn, $post->created_time); $created = date("Y-m-d H:i:s", $created); $compare = substr($created, 0, 10); $twodays = date("Y-m-d",strtotime("-2 days")); $link = $post->link; // echo $twodays . "<br>"; echo $compare . "<Br>"; $sql = "INSERT INTO userfeeds (link, thumbnail, created_at, caption, author) VALUES ('$link', '$image', '$created', '$caption', '$author')"; // $exec = mysqli_query($toolconn, $sql); echo $sql . "<br>"; echo "Created; " . $compare . "<BR>"; echo "Comparison; " . $twodays . "</br><hr>"; } } while ($compare != $twodays); ?> I have been trying to do this for about three weeks now. For some reason, my loop doesnt work. Help! In the documentation it says the following.. Each endpoint has a maximum range of results, so increasing the limit parameter above the limit won't help (e.g. getUserMedia() has a limit of 90). That's the point where the "pagination" feature comes into play. Simply pass an object into the pagination() method and receive your next dataset: <?php $photos = $instagram->getTagMedia('kitten'); $result = $instagram->pagination($photos); ?> Iteration with do-while loop.Basically my end goal is to make sure everyday I didnt miss a post.. I have been trying to work on this for literally three weeks and I have gotten nowhere Hello, I am building an online game(users make a character and move on a map and so on...)
All user data is stored in a mySQL database and I want the users to interact in real-time, but there can be a 1-3 second delay between the communication, but not exceed 3 seconds even if 500 players are playing at the same time.
But for the purpose of the question let's say the users can only chat between one another, if I'll have a solution for that then I can use the same method for more parts of the game.
I can't use websockets because my webhost doesn't support it( I don't want to use pusher.com).
I know I can make real-time apps with ajax long polling, but I think that with 500 players playing at the same time it's not the best solution.
So, finally:
How can I make user interaction as close as possible to a real-time game?
(Without too much load on the hosting server)
(I am sorry if some of my terms are not correct - I am just getting back to coding after a long time...)
Edited by Mythion, 17 August 2014 - 02:34 AM. Okay, so this is my first real php script from scratch. This is the theory of the script I am writing. Mysql database connect script already done. So, first things I need to do is connect, right? <?php //connect to db require_once ('includes/connect.php'); //connect to table $result = mysql_query ("select * FROM shop1"); //display data in table echo "<table border='1'><tr><td>Shop</td><td>city</td><td>members</td></tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['city'] . "</td>"; echo "<td>" . $row['members'] . "</td>"; echo "</tr>"; } echo "</tr></table>"; ?> Displays this, http://67.23.249.45/~gaogier/shop1.php What do you think so far? Whats still to come. How do I link 2 tables together? I mean, I plan to have many shops displayed, then, inside the shop, have the items, which will be linked to each shop. I plan to link each shop to a different page, which will be displayed like, url/shop/shopname If you are confused, i need to have a working shop database that works like this, http://www.tip.it/runescape/?rs2shops I don't care about styling at the moment, I just want the script to work. What do I do now? Hello guys, I have been searching on the internet for articles that shows me how to get the real IP address when they are behind a proxy. But after some reading it seems that this is not completely possible. Correct me if I'm wrong. So what is the best thing to do? Because I have seen different methodes and I'm not sure which one is the best. http://www.laughing-buddha.net/php/lib/remoteip Getting an unexpected end error on this and unsure as to why. Code: [Select] <?php if($players['is_banned'] == 1) { ?> <a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name'] ?> (BANNED) <? }else{ ?> <a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name'] ?> <? } ?> I am trying to send an html file (with .js formatting) to the browser from within a PHP script. The .js formatting is not being interpreted and so the result in the browser is less than impressive. Why can't I make a call, in PHP, to a url and have the results from that call directed to the browser? Hi everyone, If I have a line like this: $nfn = $brand . $model; then when the variable is echoed ($nfn) will come out like nikeair, how can I save it with a space so when echoed it will display nike air? Cheers I am trying to get the actual filename so that I can attach it to an email. I tried echo $file; but its not giving me anything. Just a blank page. Here's the code that I' working with: $file = date('M-d-Y H:i A'). '.png'; $uri = substr($data,strpos($data,",")+1); file_put_contents('./Collection_Posts/'.$file, base64_decode($uri)); echo $file; exit;
Hello I am having a problem trying to write to a database using mysql real escape so there wont be any injection attacks. I trying using myrealescape and it returns errors: Code: [Select] Notice: Use of undefined constant messageTo - assumed 'messageTo' in D:\wamp\www\Legit Gaming Upload\LGU\includes\mailCompose.php on line 17 Notice: Use of undefined constant messageSubject - assumed 'messageSubject' in D:\wamp\www\Legit Gaming Upload\LGU\includes\mailCompose.php on line 17 Notice: Use of undefined constant messageBody - assumed 'messageBody' in D:\wamp\www\Legit Gaming Upload\LGU\includes\mailCompose.php on line 17 I add in the single quotes and it doesn't write either. Dreamweaver says that either single quotes or not there is no syntax errors. What going on? I have used it like this befo ('$ID','" . mysql_real_escape_string($_POST[post_content]) . "') and no problems.. ~AJ <?php require_once('connect.php'); if(isset($_COOKIE['user'])){}else{ header( 'Location: members.php'); } if (isset($_POST['sendBtn'])){ $messageFrom = $_COOKIE['user']; $messageTo = $_POST['messageTo']; $hash = $messageTo.$messageFrom.time(); $hash = md5($hash); mysql_select_db("majik"); $sql="INSERT INTO messagesystem(ID, hash, messageTo, messageFrom, messageSubject, messageBody, messageDate, messageRead, messageDelete) VALUES ('','$hash','" . mysql_real_escape_string($_POST['messageTo']) . "','$messageFrom','" . mysql_real_escape_string($_POST['messageSubject']) . "','" . mysql_real_escape_string($_POST['messageBody']) . "','0','0')"; echo '<center>Your message was sent to: '.$messageTo.'</center>'; } ?> Hi there I am never the one to use something I don't simply understand but I was wondering if you could help me through why an errors occuring with my first attempt at a very primative MVC. Ok I understand them as being somewhat Model (data whether that be a database or a file system it's just data!), View is the way the page is assembled in (ZF that would be also the Layout right?) and then finally Controller (that handles all the user known and unknown requests), the controller is responsible for sending any responses back to the user, would you ever have view take the data from the model or would it always go via the controller? I know it wouldn't get output to the user as they may never understand it in it's raw form. But this is what I have come up with from this tutorial he http://php-html.net/tutorials/model-view-controller-in-php/ This is what I have done in I think completion: index.php: Code: [Select] <?php // NOT TO BE SHOWN IN A PRODUCTIONAL APPLICATION ALWAYS USE FALSE WHEN IN A PRODUCTIONAL SERVER! ini_set('display_errors', true); // We require the class for this to work so we do so using the require_once construct: require_once 'Controller.php'; // We ask for an object to be created of class/blueprint Controller but with no parameters $controller = new Controller(); // We then make invoke action as a function within Controller class $controller->invoke(); Controller.php: Code: [Select] <?php require_once 'Model.php'; class Controller { public $model; public function __construct() { $this->model = new Model(); } public function invoke() { if(!IsSet($_GET['book'])) { $books = $this->model->getBookList(); require 'booklist.php'; } else { $book = $this->model->getBook($_GET['book']); include 'viewbook.php'; // we could actually include this as one file though right? } } } Model.php: Code: [Select] <?php require_once 'Book.php'; class Model { public function getBookList() { return array('Jez\'s Great Book!'=> new Book('Jez\'s Great Book!', 'The best book on the planet about MVC\'s'), 'PHP5 and MySQL Bible'=> new Book('My most enterprising PHP and dynamic page content book ever!')); } public function getBook($title) { $allbooks = $this->getBookList(); return $allbooks[$title]; } } Book.php: Code: [Select] <?php class Book { public $title; public $author; public function __construct($title='', $author='') { $this->title = $title; $this->author = $author; } } booklist.php: Code: [Select] <?php foreach($books as $title=>$book){ echo "<pre>"; echo '<a href="index.php?book='.$book->title.'">$book->title</a>'; echo "</pre>"; } viewbook.php Code: [Select] <?php echo $book->title; echo $book->author; It's not the same as the tutorial exactly but I just wanted to see if I could get it working, the only problem is (I mean my sample data's just for the fun of it), however when I go to see the booklist.php The problem I am having is how to understand it getting the values into the list, when it says the 2nd one's basically not an index, does this come up for yourselves? I am just a bit confused, happy though kind of got this working, thank you in advance, Jeremy. I've developed a file upload service of sorts. Think TwitPic, TwitVid and Twaud combined and it's not that far off. I need to determine which content pages are most viewed. Right now I just count each and every page request, so... The problem I run into (of course) is that also agent/bot requests are counted, and for some reason search engines (or other services) are very keen on accessing pages with many pictures on them, so such accesses can easily "overload" and make the access counting quite skewed. Is there a black list of search engine user agents I could deploy, or is there a more generic way of knowing whether I get a request from a search engine rather than a user? I still want the content pages indexed by search engines, so they shouldn't become "invisible" to them, yet I need to be able to determine what accesses are from primarily real users. There's no need to log in to see the content, so I can't use that as a differentiator. I suspect there are also image grabbing agents accessing my pages, and honestly they could be shut out completely. Thanks in advance, Anders Hey there! So, I am working trying to get a page to edit and update field to insert back into the DB. But for some odd reason, the page just shows up vlank. I've added it to show errors, but still nothing is coming back, so I have no idea what the issue is. Not too sure if there is a config issue with PHP on my server or what. Here's my code: Code: [Select] <?php ini_set('display_errors', 1); //open DB connection include '../dbconn.php'; if ($_POST) { $msg=""; //build an update query $update = "update testspaces set status='$_POST[status]',spacenumber='$_POST[spacenumber]' where id='$_POST[id]'"; //execute query and check to see if it went through if (!mysql_query($update)) { $msg = "Error Updating User"; print $update; } else { $msg = "Record Updated Successfully"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<div class='header2'><a href='adminindex.php'>Go Back To Edit</a></div>"; //print $update; //write a table row confirming the data $table_row = <<<EOR <TR> <td>$status</td> <td>$spacenumber</td> </TR> EOR; } //if not posted, check that an ID has been //passes VIA the URL } else { if (!IsSet($_GET['id'])) { $msg = "No User Selected!"; } else { $id = $_GET['id']; //build and execute da query $select = "select * from testspaces where id=$id"; $result = mysql_query($select); //check to see if the record is there if (mysql_num_rows($result) < 1) { $msg = "No User with that ID is found"; } else { //set the variables for the form code $form_start = "<FORM METHOD=\"post\"ACTION= \"" . $_SERVER['PHP_SELF'] . "\">"; $form_end = ' <TR> <TD COLSPAN="2"><input type="submit" value="Submit Changes" /> <input type="reset" value="Cancel Changes" /></td> </tr> </form> '; //assign the results to an array while ($row = mysql_fetch_array($result)){ $status = $row['status']; $space = $row['spacenumber']; //write out into table row with form fields $table_row = ' <table border="1" align="center" cellpadding="5" cellspacing="0"> <th>Space Number</th> <th>Status</th> </tr> <tr> <td><input type="text" name ="spacenumber" value ="' . $space . '" size="20"/></td> <td><input type="text" name ="status" value ="' . $status . '" size="20"/></td> </tr> <br /> <a href="editemployees.php">Back to Employees</a> '; } // end of while } // end of else num rows } // end of else isset get id } // end of else mysql update //print message echo (IsSet($msg)) ? "<div class=\"error\">$msg</div>" : ""; ?> <? echo (IsSet($form_start)) ? $form_start : ""; ?> <input type ="hidden" name="id" value="<? echo $id ?>" /> <? echo (IsSet($table_row)) ? $table_row : ""; ?> <? echo (IsSet($form_end)) ? $form_end : ""; ?> Not too sure what could be causing to become blank. |