Good day to all.
I created a moderated chat (each question/answer/whatever have to be moderated). Now my only problem is that I don't know a way to simulate lots of users that type something and after the post is moderated get a replay. So what I ask is if there is someway to simulate users typing something then press enter. (and for each some ajax to get the response). I can moderate whatever they type or if I can simulate a moderator is even better.
Thank you for help.
Try using a dynamic web testing tool that supports sample data injection - Loadzen has a dynamic data feature: so you would record your test using their Scenario Recorder, then you would generate sample data sets for each of the recorded GETS/POSTS and attach them to your recorded scenario.
This will effectively have the same effect as simulating loads of users sending and responding to each other with sample/dynamic data, you could mix the data sets to make sure that it's random on both the answerers and askers side.
Related
I'm building a web application using PHP, JavaScript/jQuery and MySQL. Right now I'm trying to implement a chat feature that allows two user who are both online to chat with each other (e.g. NOT a big chat room, but only private chats between two users). However, I've ran into the following questions during the implementation process:
How can I let one user know whether another user is currently online or not? Now I have a page where a user can see the name of other registered users. I hope to differentiate those who are currently logged in from those that aren't. Currently, when a user is logged in, I store his username in $_SESSION['name']. So how can one user know whether another user's $_SESSION['name'] is also set?
How can I ensure that the conversation is private to two users? I currently have a page called "chat.php", where the chat interface is located in. When one user clicks on the name of another user who's also online, the two will be directed to their own "chat.php". Similarly other users should be unable to view chat that they are not involved in. I'm currently thinking about generating a unique page for the two users, like "chat.php?user1=Tom&user2=John" But how exactly should I achieve this? I'm new to PHP.
To display the new message if the other person has just sent one, can we do this using Ajax in an event-driven way? Or can we only use polling? I'm currently using polling like the following, but I feel that polling isn't every efficient:
// "logs.php" reads chat message from the database
setInterval(function(){
$.get("logs.php", {}, function(resp) {
// display the response
});
}, 1000); // poll every second
Any input to any of the above questions is appreciated! Thanks.
I am also currently working on chat right now, below answer are according to my best of knowledge if you find something wrong please comment it.
Answer 1//
With the use of session you will not be able to get who are logged in and who aren't, to check you have to set flag in database and from there you to fetch logged in user apart from current session user.
Answer 2//
Here you are mixing to different concept of chat i.e. one to one chat(private chate) and another is group chat. What I will prefer is create different chat file for both concept.
Consider a scenario where you 100 user chatting in group you will not be able to send 100 user id through ajax.
Answer 3//
Long polling is the method with which you can achieve real time chat update. But still there are so many catch to use long polling with PHP. First and foremost is the main drawback using long polling is it use more resource when user will increase.
So, in conclusion try to use web socket programming or use different framework like node.js to implement.
If you have less number of user then definitely you can use long polling with PHP.
So what I am trying to accomplish is this; I have people cold-calling potential customers. When the caller gets a potential client on the phone and has them interested, they transfer the client to a sales agent to seal the deal.
During the initial conversation, the cold-caller collects some info in a form I have online such as name, phone number, address, etc. I need the cold caller to be able to transfer those values to the sales agent when they pass the phone call over.
The cold-caller and the sales agent are in two different buildings across town from each other, and the sales agent uses an online form to collect data as well. Capturing the values is not the problem, it is the pass from one agent to another that I cannot figure out.
I thought maybe the cold-caller could post the form to a Google spreadsheet, but I do not know how to get those values to populate on the second form when the call is passed. I need the transfer to happen within a few seconds, so sending a URL with the captured values in an email won't work due to email being unreliable in the speed department.
Anyone have any thoughts on this? I can use HTML, jQuery, or whatever. I would need help if it has to be done in AJAX....
Thanks!
Ok.
This is customer side:
Customer put data into form, send this data to server.
Server must save this data for agent.
This is agent side:
Browser send check requests (maybe automatically, maybe agent need click some button) for new data from customers.
If exists new data you should place this data into form on agent page.
$('#first-form').submit(function() {
$.post('/another-destination', $(this).serialize(), function(r) {
alert('Data sended to another destination!');
});
return true;
});
Looks like you are wanting to use HTML5 and Javascript WebSockets to be able to push data from one browser to another.
Ajax requires polling, meaning a query has to ask the server for new information.
This can be accomplished by saving and comparing the last updated timestamps from a session variable.
Websockets push data to a connected peer when it is updated allowing for data to automatically populate as it is submitted, much like a real-time chat system.
If you are stuck on PHP you should take a look at Ratchet since it is fairly straightforward and minimalistic to implement in comparison to many of the alternatives.
http://socketo.me/
Chat demo using ratchet http://socketo.me/demo
Add in a RDBMS to create, read, and update the data and you have a powerful real-time application.
I'm terrible at keeping track of my bills, so I wanted to create something automated. I also wanted the challenge of making it myself.
My questions:
Is it possible to have a webpage connect to another domain (any utility website i.e. timewarnercable.com) with the proper login credentials and retrieve the dollar amount I owe, then send me an email or even just display it on the webpage?
I've already got a webpage setup that has all my account info stored in it (don't worry it's only a local site!) and I can click a button and the info I have stored sends a POST request to the utility login site. This logs me in to my account page and then I can view the bill. But don't want it to open another page..I'd rather load the content of that page in the background, scan for the code where its says my $ owed, then capture that somehow, then return the dollar amount onto the webpage.
If so, is this possible to design this with Ruby (Rails) or php, with Javascript / AJAX.
Thanks!
What you're basically asking about is "page scraping", but your scenario is more complicated. You would have to fake the login post, capture and store any cookie/session info returned to you in the response and use that in subsequent requests to the site. You may also have to deal with redirects, depending on the site.
I have found nodejs actually quite useful for scraping pages since it has plugins that provide dom selectors (there is a jquery plugin) - you're using javascript for server-side programming.
Check if the site has API and if the site provides that, will make your life a ton easier.
Some banks like BankOfAmerica have applications that already do this - they aggregate your accounts and bills from other sites, see if your bank can do this.
I'm looking at a domain registration site that looks like it uses jquery to process users data inputed and to register domains.
What I was wondering is if it's possible for users to be able to fill in data on a form on my website and then when the user is ready to complete payment, be taken to the actually domain registration site where all the data they typed in on my site will be posted to the domain reg site.
So basically, the users fills in a load of info on my site, AND attempts to check for domain availability on my site. Once the users has found the domain they want, they will be redirected over to the actual domain reg site where all their info will be posted.
Now I know if the domain reg site used PHP to process all the stuff, it wouldn't be a problem. But they don't use PHP.
Do you guys reckon this could be possible?
I'm not sure this would be possible in any amount of time that would make it worth it to you. Without knowing any of their back-end code, it's going to be extraordinarily difficult. Edit: I should add that I did look through some of their jQuery code and it looks as though they're using ajax .post() to submit data. Where this data goes and what responses are expected is anyone's guess, though...
That said... there are quite a few domain registrars that offer real APIs to let you do what you want... or even let you go one step further and offer the ability to register domains directly through your website. Sometimes you can set your own price, as well.
Here are links to some of these APIs:
Namecheap: http://developer.namecheap.com/docs/
GoDaddy: http://www.godaddy.com/reseller/domain-reseller-api.aspx
eNom: http://www.enom.com/resellers/Interfaceinfo.asp
I'd personally recommend NameCheap, but for the purposes of your question, any of these should do.
I can't make any promises but say you used jquery ajax to pull in the form the would have to fill out. Said form would then be on your client side so in theory I think you could use their input ids to fill out the form using javascript/jquery. All this would technically be client side. To bad that other site does not have an api for purchases.
Do you have control over the domain registration site? There are many ways you can send the user's input over to that site, but of course it has to be looking for this posted data and know how to handle it. PHP is not necessary to handle the data that is passed in. For example, if you send your info to the domain registration site via a form GET method, the info will become part of the URL, which can be accessed and parsed via javascripts window.location property.
I am developing an online learning system (PHP, MySQL and Javascript). I would like to track what pages and how long each users spent on each page. Ideally, I would like to record this in a MySQL database. My question is 2 fold:
1. What kind of fields would I include in my db table to record multiple pages accessed?
2. Is this problem best approached by server side only or by using javascript ? e.g. server side: hidden form fields with a page id attached, page id is passed to db and recorded?or Javascript: record all actions in Javascript variables and somehow pass to db at end of session?
Really I am just looking for some high level guidance on an approach as opposed to code snippets.
GF
PHP isn't my normal language, but I would think about creating a module of code that can be called from the top of each of your scripts, that basically logs away "I served this page, with these form variables, at xxx ... ". To be more precise, I would record that in a table.
If you need to know when the user left your page, for a page on another site or perhaps shut down their browser for instance, then a purely server side solution isn't going to cut the mustard. In that event, you are going to have to start thinking about JavaScript, and intercepting events - such as the onUnload event...
Have a read here...
While I know of no solution that can track individual users out of the box (I'm sure there are some), I am pretty sure you could customize Piwik to do this. Piwik aims to be a self-hostable alternative to Google Analytics. It is open source and build on Zend Framework and MySql.
Piwik collects usage statistics through a JavaScript tracking code and a Webbug image for fallback. Basically, what you would need to do is pass the logged in user's user id to the tracking script and then write a plugin that knows how to handle this information.