How to fetch data from website without API - php

I want to fetch all current and future courses form this website http://www.scfhs.info/cme_pd/search/index.php for example this queries http://www.scfhs.info/cme_pd/search/do_search.php to my iOS app , unfortunately they don't have an API.
How to get the data?

Check this out https://www.parsehub.com/ this will help you for sure

I've done this for a project, search for html scraping. There are a tools to do it that vary depending on your platform. Here is a start. Unfortunately if the page changes you have problems. In my case the pages would update in an inconsistent manner. It looks like most of the data you want is in option tags; that should make it easy to parse.
I would have made this a comment, but I'm not worthy yet.

Related

Using cookies, change "unviewed" to "viewed" in db when user views page

I'm trying to make a notifications system from scratch after looking around at ready mades and possible integratable versions that fell short.
I'm focusing on one aspect first: notifications for comments.
My database table comments looks like this: !(http://oi43.tinypic.com/2zgtaoz.jpg)
When a user submits a comment the recepient's ID is added to the field to_id.
unviewed is the default status of every comment.
Then I made this code to check for all unviewed comments:
SELECT COUNT(*) FROM comments WHERE to_id='$myid' AND status='unviewed'
I made some dummy comments and the count works 100%.
I also made a dropdown box to view the notifications in but the code is really long and not crucial to what I need to do next so I'll omit it unless needed to clarify later.
Now I'm trying to find out how I can change the value in the status field to 'viewed' when a user clicks through to it from their notifications menu.
Does anybody know how I can achieve this using php and cookies? Just looking for a point in the right direction, my mind is a bit frazzled after writing code all day.
Does anybody know how I can achieve this using php and cookies? Just looking for a point in the right direction, my mind is a bit frazzled after writing code all day.
You shouldn't reinvent the wheel. Just use one of the analytics frameworks available, such as google analytics. Note this is usually a paid service.
The approach you propose is slow, not scalable and rather limited.
The way it works, you just add a reference to JavaScript code. This code is located on a content delivery network, which means it is fast to get to the user. Usually, it is much faster than your production server. The code tracks a lot of user activities that can be valuable to a business. In most cases, such analytics is backed by nosql database.
Disclamer: I am not connected to any analytics framework in any way.
When you click a notification, I assume it is something basic like a checkbox or similar.
Just do a AJAX request or a simple POST request to a page called, maybe notif_read.php
There, get the value of the checkbox clicked and do a database query as follows:
"UPDATE Comments SET Status='viewed' WHERE to_id = '$myid' AND status='unviewed'"
Also, try using a simple boolean datatype for the status, since it makes things easier to update and check. Just a thought, will work as it is now.

Creating a user-specific calendar

I want to create a fairly simple webpage where a user logs in and can manipulate a calendar that I create (perhaps with a HTML table?). I've already created a simple login service with a few HTML and php pages and have basic user info stored in a MAMP server.
Correct me if I'm wrong, but from here I would need to layout a calendar in HTML and maybe have link table cells to an edit page where the user can create a new event. The real question here is what is the best way to go about storing information like this on my server? Using PHP and MAMP like I did with the form data at registration?
I'm still fairly new to databases and working with servers and such, so just looking for a little guidance so I don't waste time learning a completely incorrect approach to this.
MySQL and PHP are definitely the way to go in my opinion. I would look into Javascript and AJAX if I were you also. Using AJAX, you could have a user enter information into the calendar directly and store it in the database without having to leave the page. jQuery is a very nice and simple library for working with Javascript and AJAX and I would very highly recommend it. It greatly simplifies working with Javascript.
As for the calendar itself, using a table seems like the best approach to me.
For storing information in MySQL, I'm seeing a table somewhat like this:
UID|EntryID|Date|Time|Event|etc.
You could store this table separately from your users table and join them easily when making requests. For instance, when a user logs in, you can pull the users UID from the users table you have set up, then pull all entries out of the calendar table with matching UID's and manipulate and display this information with PHP and Javascript.
There may be (and most likely are) better ways to set up your database, but this is kind of just a general concept of how you could get it to work. There are certainly people here with much more experience in MySQL and database design than myself.
Overall it sounds like you have a good idea working for you and have a pretty good idea of what it will take to make it happen. I wish you the best of luck on your project!

Setting up an online server database and code my android native app to interact with it

Im developing a very simple native Android App containing a simple Main Menu with the Today, Yesterday, This Week, This Month and Search by Date options.
(I bought the lynda course: "Building Android and iOS Apps with Dreamweaver" with HTML5 and with the design and functionality of the app im not having too much trouble.)
What i entend with this app is this: i will write famous people profiles every day (between 1 and 5). So when people click (for example) in the Today option they will access to the profiles list that i have created for today (Yesterday and others is a check on the past written profiles from database).
So imagine that some android user clicked on today and will be presented with 3 profiles options ("Brad Pitt", "Shakira" and "Cristiano Ronaldo"), that i need the app to access my server database to update it (the "Today" profiles).
and finally...
Before the questions i want to say that i have searched on stackoverflow and found very similar answers, but im a novice on programming and when i'm reading the answers they can differ so much that i got confused going link on link documentation.
The Questions:
I want to create somekind of method that i could have a template with different profiles (Singer, Politician, Soccer Player) and click on somekind of button to start a new profile/article with Born Date, Occupation, Nationality, Biography and etc. Its this possible? How can i do it and in wich programming language?
What kind of server and what kind of database do i have to create and how to configure it to send the info to my app?
There is any server specifications that i must have for this to work the smoother and easiest possible? For this issue price is not a problem.
What kind of code should i write on my app so that it could get the "3 profiles update for today" from my website?
Its possible to show me some code example that would work with this simple step in my app of selectiong "Today" button on main menu and the app check for new profiles for today and present the user as an option? Because if i had this bit of code i could understand better how to do the rest with the profile details on the "Brad Pitt" option for example.
Hope you understood my questions. Thanks in advance. Have a nice day
Assuming that you're using the Phonegap Framework to develop your application, I would do it like so:
First of all get a Server/Webspace capable of running PHP Scripts and a MySQL Database.
You also have to rethink the way these applications work, for example you can't
configure it to send the info to my app
You need a Server Side Script (i would choose PHP for this, it's easy to learn and available on almost every Server). This PHP Script then queries your MySQL Database where all the information about the people is stored. On thing to remember is that your Clients will poll the server and request the content, you're not actively sending anything to Clients unless requested, that's just the way how HTTP works. The interface your Script is providing there is called a REST Interface.
Have a look at the link, it explains everything pretty good. Your output format should be JSON this makes it really nice to work with in the Client App later on. To do things like "what was posted today?" Have a look at how SQL Queries work and implement it in your Script.
Now for the client you can access this data by using JavaScript, most likely jQuery to simplify everything a bit. Use the jQuery $.getJSON function to access the data provided by your REST Interface. Now you can use basic jQuery to wrap this data up with HTML to present it to the user. I know that this is not "example code" or anything you requested, but it should point you into the right direction on how to achieve something like you want to do. Just do a google search for all the keywords listed above and keep reading about it, then you should be able to build a app like that.

Communication between websites

I'm creating a network of websites that should communicate between themselves, for example to let all of them display an article published on one of them, or display data stored in a database of another subdomain, etc...
And this all using ajax for interactivity.
Which could be the best (and simplest) way to achieve this?
I thought an ajax call could summon a php script that could call another script on another subdomain. Is it the right way?
Thanks
I don't know exactly what you want to do. If you control the sites and server you could save all your users a lot of ajax calls if you skip doing it that way and do it on the server itself.
If you display all the articles by using javascript, users without javascript won't see anything and search engines won't be able to crawl the website.. however, maybe that's what you want.
The correct design pattern for something like this is to implement a restful API that all the other sites read from..
So you have a central API on eg. http://api.example.com/
and when a server wants to display an article, he would do something on the back end to retrieve an article list.. eg.
http://api.example.com/retrieveNewestArticles
that would return eg. a json variable with a list of the newest article.. then when you want to display that article, you would call:
http://api.example.com/showArticle/58484
That's how I would do it at least.
Some people might suggest doing it by making all the websites connect directly to the same database. That's an option, a bit more messy in the long run, but will get the job done.
certainly easier than my suggestion.

CHAT IM client (browser based, using JavaScript/jQuery and LAMP) like meebo or imo.im

I am using imo.im for last few days. I want to make something with similar kind of functionality with LAMP and javascript/jquery.
I already have a table in MySQL with name as user_account_details. Where i have columns as userID, protocol, protocol_username, protocol_password, with values like these: {123, facebook, 123_username, 123_password} and so on..
I know the term 'protocol' is not relevant here, but I can't think of anything else.
I don't need the complete code. I only want someone to show me the correct direction. I don't have any idea how to do this.. And how these multiple protocol chat clients works.
Any reference LINK would be a great help...
Is this very tough to do??
Thanks
Since you are looking for a PHP based application checkout Jaxl library. It contains several sample application for getting started quickly. Specifically checkout echobot/sendMessage examples for command line based applications (basically bot). Check boshchat/boshMUChat examples for browser based application.

Categories