Simple Laravel route not working - laravel-5.5

I am currently in the middle of doing a Laravel tutorial on Youtube and I've been catching on pretty quickly but I hit a snag and I have absolutely no idea what the problem is. I'm trying to route to a view and I am receiving an error saying that the page does not exist. Here is what I got (forgive me if my terminology is lacking):
The web.php file in the routes folder is configured for 'companies' to go to the 'CompaniesController':
Route::resource('companies', 'CompaniesController');
The create function located in the CompaniesController only purpose is to return the view 'companies.create' located in the appropriate place, 'resources/views/companies/create.blade.php'
public function create()
{
//
return view('companies.create');
}
If more information is needed let me know but this should be pretty straight forward. Other functions in the controller work fine, its only the one that is the most simple that isn't working.
Appreciate any help I get.

If your http request is GET:
Route::get('/companies', 'CompaniesController#create')
Else if request is POST:
Route::post('/companies', 'CompaniesController#create')

create would respond to a POST request by default, e.g., the endpoint of a creation form. It sounds like you're trying to display a simple view with a GET.
See https://laravel.com/docs/5.5/controllers#resource-controllers

Related

Get page insights and post insights in the same request

Hello i am trying to get page level insights and post level insights in the same request but cant seem to get the syntax correct.
page id /published_posts?fields=permalink_url,created_time,message,shares,reactions.limit(0).summary(1),comments.limit(0).summary(1),insights.metric(post_reactions_by_type_total,post_impressions_unique,page_posts_impressions_organic)&since=yesterday
This is my request for now but i wanna add page insights like page_fans and page_fans_city.
How can i do that?
You are using the published_posts endpoint there already, you can not go back “up” to the page object from there. You need to rewrite the whole thing so that you use the page id itself as the basic endpoint, and then request everything else via the fields parameter. The trick is to get the syntax and nesting right …
/page-id?fields=insights.metric(page_fans,page_fans_city),published_posts{…}
should work, inside the {…} you then put all the original fields you requested from the published_posts endpoint before, so
/page-id?fields=insights.metric(page_fans,page_fans_city),published_posts{permalink_url,
created_time,…,insights.metric(post_reactions_by_type_total,post_impressions_unique,
page_posts_impressions_organic)}
And &since=yesterday then just goes at the end again, after all that.
To have the since limitation still apply on the post level, it apparently needs to be added on that “field” again, syntax similar to .metric():
?fields=…,published_posts.since(yesterday){…}

Cant get HTTP Post result of Website

Sorry for my bad english.
I am working on a Teamspeak plugin.
I am trying to get the website content, where I posted some Parameters.
The Website is http://ts3.cloud/ts3proxy and the Parameters which I found with a sniffer are "Input" and "port".
When I call http://ts3.cloud/ts3proxy?input=testserver.de&port=9987 the results not same as when I go to Website, type in Manual and use the Buttom.
Can someone say why it is like this? What should I do that I get the right result?
Xploid.

CookieAuthenticator restlet

I have built some RESTful api's with REstlet 2.3.4. I've been using HTTP_BASIC which let the browser prompt for credentials but it's time for a proper login form. I figure the easiest way to implement this is CookieAuthenticator. I can't find full working examples on github/google. I am sure i'm over looking them can someone provide a working example implementing CookieAuthenticator in Restlet?
I did get this to work after all. I have a longer answer here with some code examples. First, i was missing the fact that CookieAuthenticator is a filter and HAS the logic to handle login and logout. You need to create EMPTY ServerResources with a method annotated with #Post that has nothing in the body. Second, extend CookieAuthenticator and overwrite isLoggingIn(..) and isLoggingOut(..) with the code found in the link.
Cheers,
-ray

How does the SendToKindle work?

I'm been research on SendToKindle function, currently I'm using the Chrome SendToKindle Plugin. I want to implement this kind of function by using a web-service.
From what I see, the "SendToKindle" is analyzing the webpage by send the page to the amazon server, and then it will return a new url which will only contain the main article(Without any other elements).
e.g.
I reading this article:
http://www.nicholascarr.com/?page_id=21
use Chrome SendToKindle:
I got following new url:
https://www.amazon.com/gp/sendtokindle/reader?article=1392945012941
Dose anyone know how it this been implemented ?
Any help will be highly appreciated
Thank you

How to catch and view the JSON response?

I have this following view which I get data from a model and thereafter serialize it into JSON.
views.py
def polling(request):
if request.is_ajax():
data = UserReview.objects.filter(movie_id=request.GET['m_id'])
serializers.serialize('json', data)
return HttpResponse(data, mimetype='application/json')
else:
raise Http404
At the client side I want to show this content now. I'm using jQuery's function getJSON to archive this. It won't show anything, and the setTimeout doesn't work as well. But I get a response when I debug it with firebug, it however doesn't call the alert() function to view the data. I've been trying to figure out what the problem could be for some time now. So I wonder if there's something wrong with my script?
javascript
function polling() {
$.getJSON( "/polling/",
{m_id: {{movie_info.id}} },
function(data) {
alert(data)
setTimeout(polling, 5000)
});
};
Some general methods that will help you find out what is wrong.
Use console.log very liberally on the front end to make sure everything is going as planned
http://api.jquery.com/jQuery.ajax/ Callback functions as suggested in a comment, make sure you at least logg an error
https://docs.djangoproject.com/en/dev/topics/logging/ set up a debug logger, make sure that you can see what is going on and what django is actually returning as json.
http://docs.python.org/library/pdb.html Better yet drop this badboy anywhere in your code and MAKE SURE that everything is going the right way. If your success is not being called ont the front end i bet the error is in django! find out where.
You can view the errors in the HTML tab in firebug if debug=True or you can just request /polling/ through your browser and view the django error screen.
using some or any of these should put you in a fine place to solve your problem django dev server makes it an absolute ease to breeze through these errors please do some research and find out the many many debug tools made available to you!
I'm new to all of this but have you tried to use.
$.ajax
({
url: "/Build/AllStatuses",
dataType: 'json',
success: function (buildstatuses)
This is how I used to call my json and it seems to work.