Creating an API (in cakephp 1.3) and Delivering HTML - php

This is not truly an API scenario. I know APIs deliver content in XML or JSON. I am not looking for someone to tell me how to do this but to give me a good starting point and some tips or tell me this is a stupid idea.
WHAT I WANT TO DO
Client User needs to be created through another website
Client needs to be authenticated through another website
Client needs to request pages that are HTML.
Client will need to save data to our database from these pages.
We will need to track each created user
We want the person implementing this "api" to their site to be required to have as little programming knowledge as possible.
Your input is greatly appreciated and valued. Thanks!

I think my best solution will be to use an iframe.

Related

Effective method on broadcasting the same notification to all the users in the database

Hello guys i'm building a social network with HTML, CSS, plain JS, AJAX, MYSQLI, and PHP.
I been wondering what's the best method that you guys know personally from experience that is used to broadcast the same notification to all the users in the database.
Lets say I have a million users how would that work? I'm trying to find the most effective method on how to do this without making my database work really hard.
This is how my table look like.
I'm not asking for anyone to code for me. All i'm asking is advice on a method that works best so I can get ideas on how to code this result effectively.
You are probably looking for some pub-sub service. You can find lots of free ones to start with.
Take a look at https://cloud.google.com/pubsub/docs/ or https://aws.amazon.com/sns/
The idea is to publish the message from the server and have all the users subscribe to the channel/topic that the server is broadcasting the message to.
For a quick overview, you can refer to https://faye.jcoglan.com/

Communicating with a Wordpress database

This question is a bit wider than accepted on SO, but I need to start somewhere as I am a bit new to some things.
I am developing an iOS/Android app for a client who has an online store based on Wordpress.
Inside the app, the user logs in using their user credentials that he/she has created on the online store, where the underlying login system is handled using webrequests
His WP site has a database called store_locations consisting of longitude and latitude fields, and I need to somehow read the fields from the app.
What I am wondering is:
would I need to create a custom PHP script to access the DB?
How is security handled such as user verification?
Where is the PHP script placed on the server?
NOTE:
Please let's have a discussion in the comments first, as I might need
to fine-tune the question as per request if anything is unclear.
EDIT 1
I found the following video https://www.youtube.com/watch?v=f7ID_L91lIk
where the instructor at 19:00 to 20:51 talks about what I'm assuming would clarify question 2 from above.
If you are going to interact with Wordpress from an external source you should use WordPress REST API.
You need to fetch data from a custom database table, so take a look at Adding custom endpoints.
As you said, this is probably too broad for here. I suggest you create a plugin that gives you ajax access. You can study up on that here and then when you have more specific questions, let us know.
I understand that you asked to discuss it in the comments first, but there is just not enough to discuss here and that is asking quite a lot for an undeveloped plan.
If you have more questions, feel free to comment here.

How do I create a web service that will display in a browser and on an android?

My web development experience has mostly been setting up a CMS like Wordpress or Drupal and creating custom themes. Actually work in server-size coding has been very minimal. I've played around with php a little, trying to mod off of phpBB and beginning to learn some MVC work with CodeIgniter. Overall, this seems like a pretty big step forward, but it's something I need (I think) to do for a project I am working on.
Essentially what I want to do is have a service like Twitter of Facebook (not in the social networking sense); a user is able to log into the site and perform various operations, while also being able to use an android application that supports limited operations.
After some Googling and reading articles on the internet, it appears REST is the way to go. But I can't quite seem to grasp some of the technical details. I understand how the HTTP Request/Response works, but I don't know how I can code everything server side so that visiting example.com/item/1 will bring up the details of item 1 in the browser and can also perform a GET Request in my Android app so it can grab the details from the database and display in on the site.
Any suggested readings or some tips on how to execute this?
You can implement this using MVC. By default, have the controller ask the model for the details of the item, then pass the info to the view. Repeat this process for each type of request you want to accept such as POST, PUT etc., where you define a new function in the controller, ask the model to perform the corresponding database action, and return the response to the view.
There is helpful tutorial for getting a REST server up and running using CodeIgniter here

Easiest way to allow outside developers to integrate a few basic functions from my web app?

I have a small web app written in php / mysql that stores customer information and does various things with it.
One of my users has expressed interest in integrating my app with the custom software (also web-based) that they use for setting up customer appointments.
Basically they want a system where, when they create a new customer account using their online software, that information is automatically relayed to my application, to create the customer account on my end as well. This would save them having to enter the same information twice.
I am wondering what your suggestions are for the easiest way to approach something like this? Do I have to create a full-blown RESTful API? (I have never done anything like that before and am not really sure where to start with such a thing.) Or is there a simpler way?
Any ideas or suggestions would be much appreciated. Thanks (in advance) for your help!
In order for another application to communicate with yours, you will have to create some type of API, whether it be RESTful or not.
Personally, I recommend REST as it is fairly trivial to setup and there are LOTS of tutorials on the internet to show you how. If you use Zend Framework, it's 10x easier as they have a REST controller you can extend and quickly build an API with.
Something very simple, which has worked for me is to simply accept the information as a POST. The other application will send the information via POST, which you process in your php, and store it in mysql. if the data is sensitive, you can set up a cert and go over ssl.

How to create a widget in php & javascript?

I have a website for a client offering information from a database. But other websites want to show that information in their website, so my client ask me for it.
Since the begining I thought it might be something similar to the twitter widget. As I want to give out a code similar to this:
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({ ......
And other websites will show the information from my database.
But I cannot find a exactly example, I found this: http://tutorialzine.com/2010/03/who-is-online-widget-php-mysql-jquery/
But it is not exactly what I want.
My deployment is the following: In the server I've got a mySQL database and a website, I would like to create php and javascript code (or even jquery, but I'm not very expert with it) so other website could incorporate the information from the database in a secure mode.
Could anybody give a hint?
You'll need a RESTful service on your server which other sites can ping. You will use an AJAX request to get the information from that service.
The big piece of this for you will be creating a JavaScript object that has all the functionality you want. It is much easier to give people directions on how to use your REST API and let them implement it via AJAX on their own pages. If you really do want a full widget, you'll want to check out a lot of things. First is closures in JS to ensure you don't conflict with any of their variables. Also make sure you are good at developing cross-browser Javascript independent of libraries. And finally, you'll want to make sure your server is configured for cross-domain AJAX requests. Again, my recommendation is to set up a REST API for them, and let them do the dirty work.
There is an interesting tutorial about how to create a twitter widget using PHP and JavaScript on the nettuts website, I think you may find it useful.
Well, although it's not specific for PHP, this is by far the best resource I could find to this subject:
http://alexmarandon.com/articles/web_widget_jquery/

Categories