Rest API shopping cart get with json data

getting a handle on the basics of a restful system with php

Page 1 of 1

2 Replies - 4658 Views - Last Post: 06 November 2010 - 04:25 PM Rate Topic: -----

#1 Guest_ScriptKid*


Reputation:

Rest API shopping cart get with json data

Posted 05 November 2010 - 04:49 PM

I have a webservice to give me a new shopping cart when I use Get it needs to be done using a restful API with php and returns a json type file from the tutorial I have found all I should have to do to get the data and print it to the screen is
<?php
$url = "http://localhost:14204/carts/new";
$response = file_get_contents($url);
$obj = json_decode($response);
echo $obj->id;

?>


that is all I am trying to do but I cannot even seem to get that running I am very new to the restful API and because its more like a set of guidlines then a hard fast thing like soap all the info I have been able to find is very generialized. The error I keep recieving is

Warning: file_get_contents(http://localhost:14204/carts/4cd188dc92efe1fdba000003) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /usr/home/abarnet/public_html/cset4100-hw3/resttest.php on line 3

I honestly do not see what I am doing wrong here. Any advice would be greatly apperciated.

Is This A Good Question/Topic? 0

Replies To: Rest API shopping cart get with json data

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Rest API shopping cart get with json data

Posted 05 November 2010 - 06:01 PM

The file you're calling, resttest.php appears to have some sort of syntax error. Try it in a browser too, without the PHP.
Was This Post Helpful? 0
  • +
  • -

#3 PatMan267   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-November 10

Re: Rest API shopping cart get with json data

Posted 06 November 2010 - 04:25 PM

Dude, i bet we from the same class man. i did the same thing show the 500 error to him. didn t get any reply lol

This post has been edited by PatMan267: 06 November 2010 - 04:27 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1