I found few posts on this subject, however I would like to know the best practice to accomplish the following scenario:
I am willing to make a call to a 3rd party web service, that I will provide in my call few parameters, being one of them a POST callback to my website. The response will send me a token, that I should utilize on my following service calls.
I could send them (for example) a callback URL like this:
http://www.example.com/response.php
However, I was wondering how could I use an URL hiding my php file, like this:
http://www.example.com/Response/
I found few articles mentioning redirect, but there are many options on that, and since I'm new to Wordpress, I was wondering if someone with experience on this could give me some advice to be on track to make it the right way.
Sorry if this question was answered before, but I honestly found dozens and dozens of similar requests, but none of them that I found was clear as a best practice.
Many thanks!
Update:
I forgot to mention couple things:
1. I am planning to create a plugin from this, so it should be something that should be configured programmatically, while installing the plugin.
2. The URL that will be called by the remote client, is not a page, just an URL that will resolve into the php file with my code.
I hope it makes sense.
Thanks!
Related
So I've worked through the foundations of laravel. But for my own project, there will be a login on the front page, along with obviously other stuff.
So here, I'm torn to, should I use a single controller to deal with the frontpage and the auth? Or can I somehow use two controllers to simplify the look and feel of the code? Is there another way to somehow embed the logins cript on the front page. Like a jquery fetch /loginpage/ for a div?
So my question is, what is a standard and good way to deal with a auth system from the front page, when there are also other things to load on the page?
Thanks!
Okay. Thanks for the attempt to help. I know now that stackoverflow only works if you have actual code to troubleshoot. Reddit did a better job answering this.
I really don't need to know more about php service oriented programming to get this done. I'm sure it's a "broad" question, but I am asking for a standard way to put a login on the front page. It is specific enough. I'm sorry, this community has helped me a lot, but I don't get why this community is very negative to non-code specific questions...
https://www.reddit.com/r/laravel/comments/3s0u7x/dealing_with_login_on_frontpage/
Reddit solved my problem.
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
I'm trying to create a REST service which shows/adds/deletes/edits soccer data in a database.
I've made a design of how I could achieve this, but it becomes quite complicated.
For example, when a goal is scored, what URL should I call?
So the question is, am I going in the right direction or do you advice something way different?
I agree with Abhiniav's answer except on the fact that PUT should not always be used for editing. It should only be used when you are sending the new complete resource. If you are sending a modification or partial, use POST, or the lesser known PATCH.
Reading up on Safe and Idempotent methods should be useful.
You would most likely use POST or PATCH to update the goal count: /{country}/team/{team_id}/goals.
The biggest reason something isn't REST is because services are not discoverable. Read up on HATEOAS.
Everything seems fine in your structure except that you should switch PUT and POST.
PUT can be used for both updating/creating records. In case you know the resource ID before hand, you can use PUT.
POST is used when you would be creating new resources whose IDs you would not know.
Stackoverflow has a pretty detailed discussion here:
PUT vs POST in REST
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/
I would like to know the best practice to use when listing items from a database in an ajax call with Zend Framework. The end result is to show notes concerning a customer in a css popup when clicking on a link.
I'm currently looking into using Zend_Json_Server, but I can't really see how I could implement it. Is Zend_Json_Server good to use in these cases - and if so, should I use it outside the MVC structure as some suggest?
Most importantly:
Could someone please give me an example of how it could look like?
From Calling the javascript function from the view to listing the items in the CSS div (popup).
This would help immensely and would be really interesting to know about!
KR
Josef
I have certainly seen commentary - I think by MWOP himself - that you want API service calls to be fast; if you are only returning JSON, for example, then you don't really need the full MVC. On the other hand, the context-switch action-helper is part of the MVC stack and is often used to handle AJAX calls. I guess idea is that if your AJAX call needs to perform much of the same processing as a standard MVC request, differing only in the return, then it might be DRY-er, albeit slower, to simply use the context-switch. If speed/performance is the issue, then perhaps a separate service might be warranted.
But I confess I have no experience here, so if I am just shooting crap, please feel free to correct me. ;-)
The MWOP link above contains some ideas for how to set up service endpoints.