php - POST request method via a call to GET, SlimPHP, RedBeanPHP -


tools i'm using: slim framework & redbeanphp

i'm studying article: http://www.ibm.com/developerworks/library/x-slim-rest/ , method:

// handle post requests /articles $app->post('/articles', function () use ($app)  {     try  {   // , decode json request body         $request = $app->request();         $body = $request->getbody();         $input = json_decode($body);           // store article record         $article = r::dispense('articles');         $article->title = (string)$input->title;         $article->url = (string)$input->url;         $article->date = (string)$input->date;         $id = r::store($article);              // return json-encoded response body         $app->response()->header('content-type', 'application/json');         echo json_encode(r::exportall($article));  } catch (exception $e) {         $app->response()->status(400);         $app->response()->header('x-status-reason', $e->getmessage()); } }); 

i run application or refresh/enter whatever like, don't see reporting of post in console in article?

i'm expecting see: http://www.ibm.com/developerworks/library/x-slim-rest/#f5

in console.

instead get: http://acookson.org/?attachment_id=1221

it's request method right? how author trick browser reporting post request without use of html form?

with line hear say:

// , decode json request body $request = $app->request(); $body = $request->getbody(); $input = json_decode($body);  

well i'm copying article like , nope - nothing added database either.

i can acheive similar curl

$ curl -i -x post -h 'content-type: application/json' -d '{"id": "3", "title": "programming c++", "url":"http:\/\/www.google.com\/programming\/c++","date":"2013-01-10"}' http://example.localhost/articles http/1.1 200 ok date: mon, 01 apr 2013 08:52:50 gmt server: apache/2.2.22 (ubuntu) x-powered-by: php/5.4.6-1ubuntu1.2 content-length: 116 content-type: application/json  post [{"id":3,"title":"programming c++","url":"http:\/\/www.google.com\/programming\/c++","date":"2013-01-10"}] 

with row 3 added database:

mysql> select * articles\g; *************************** 1. row *************************** id: 1 title: search , integrate google+ activity streams php applications url: http://www.ibm.com/developerworks/xml/library/x-googleplusphp/index.html date: 2012-07-10 *************************** 2. row *************************** id: 2 title: getting started zend server ce url: http://devzone.zend.com/1389/getting-started-with-zend-server-ce/ date: 2009-03-02 *************************** 3. row *************************** id: 3 title: programming c++ url: http://www.google.com/programming/c++ date: 2013-01-10 3 rows in set (0.00 sec) 

what missing?

it's not clear have asked.

"it's request method right? how author trick browser reporting post request without use of html form?"

yes, right, author haven't mentioned on how posting data, using html form.

author might have used rest client plugin in browser. perhaps similar addon.

i can achieve similar curl

sure can.

actually problem not within context slim or php.

so might need clarify problem in more detail corrected tags.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -