Non AMP
Sky Blues Talk
  • Home
  • Forums
  • General Discussion
  • Technical Support / Computing / Gaming
This is a mobile optimized page that loads fast, if you want to load the real page, click this text.

Building web API (1 Viewer)

  • Thread starter jon92
  • Start date Nov 9, 2013
Forums New posts
J

jon92

New Member
  • Nov 9, 2013
  • #1
In need of some help building a website API. I'm trying to build a website API for a film review website and when testing the API in apigee console it's not getting the data from the MySQL tables I have already created.

Anyone got any ideas?
 

Nick

Administrator
  • Nov 9, 2013
  • #2
When you say api do you mean so other people can access them?

Do you get any errors?
 
J

jon92

New Member
  • Nov 9, 2013
  • #3
Well the error I'm getting is page not found but it is definitely there
 

Nick

Administrator
  • Nov 9, 2013
  • #4
Have you checked the paths?
 

Bagsy

New Member
  • Nov 9, 2013
  • #5
Might also be worth using Firefox with the Firebug Extension. I use the 'Console' mode on firebug at work, it's great for drilling down into errors in greater detail.

Just run firebug and recreate the issue with the console running.
 
J

jon92

New Member
  • Nov 9, 2013
  • #6
this is the url im using in apigee console: http://creative.coventry.ac.uk/~3839203/filmreview/v1.0/index.php and i get a response 200 saying that fine.

its when i try adding /films to get the data from the mysql databases i get 404 not found

im testing on chrome
 
J

jon92

New Member
  • Nov 9, 2013
  • #7
this is my code ive been using

<?php
require(APPPATH.'libraries/REST_Controller.php');


class Test extends REST_Controller {

function simpletest_get() {
$data->name = 'HELLO';
$data->university = 'coventry';
$this->response($data, 200);
}


function film_get() {
$this->load->database();
$sql = 'SELECT * FROM films;';
$query = $this->db->query($sql);
$data = $query->result();

$this->response($data, 200);
}

function films_get($film_id) {
$this->load->database();
$sql = 'SELECT * FROM films WHERE code = "'.$films_id.'";';
$query = $this->db->query($sql);
$data = $query->row();

$this->response($data, 200);
}
}
 
J

jon92

New Member
  • Nov 9, 2013
  • #8
just sorted it now changed "where code" was to "where id" and on line 23 changed function films to just function film and now it lists the film in my database.

thanks for peoples help may need more in a few minutes
 

Bagsy

New Member
  • Nov 9, 2013
  • #9
Just a tip with regards to SQL statements (not sure whether you do this already). When I'm writing apps that use some SQL scripting, I normally build/test my scripts in the SQL client (In my case MS SQL Management Studio). This is because I can then see the results/ errors of the script from the native client.
 
J

jon92

New Member
  • Nov 10, 2013
  • #10
Bagsy said:
Just a tip with regards to SQL statements (not sure whether you do this already). When I'm writing apps that use some SQL scripting, I normally build/test my scripts in the SQL client (In my case MS SQL Management Studio). This is because I can then see the results/ errors of the script from the native client.
Click to expand...

Never used that before might give it a try in the future. Need to get my users table linked now.
 
You must log in or register to reply here.

Users who are viewing this thread

Total: 2 (members: 0, guests: 2)
Share:
Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email
  • Home
  • Forums
  • General Discussion
  • Technical Support / Computing / Gaming
  • Default Style
  • Contact us
  • Terms and rules
  • Privacy policy
  • Help
  • Home
Community platform by XenForo® © 2010-2021 XenForo Ltd.
Menu
Log in

Register

  • Home
  • Forums
    • New posts
    • Search forums
  • What's new
    • New posts
    • Latest activity
  • Members
    • Current visitors
  • Donate to the Season Ticket Fund
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?