Retrieve JSON response when creating video on Brightcove - brightcove

I followed the example on http://docs.brightcove.com/en/video-cloud/media/references/reference.html#Video. The response gets shown in an iframe. However, I would like to be able to get the JSON response in order to store the data (i.e., Brightcove video ID) in my own database. I tried using AJAX post but Brightcove doesn't seem to accept post requests from a different origin. Is there a way to simply get the response data without displaying it in an iframe or in a separate window?

You can't get the response data in javascript since the API response does not include CORS headers. You'd need to do this in server-side code, which also has the advantage of not exposing your API token to the browser.

Related

Spring Boot Rest Controller showing data on get request

So basically I have a Spring Rest Controller that returns an object. I call the method from my JS file to retrieve data and it works great. I know I can hide certain data and stuff but is there a way that I can hide the data showing in the browser. What I mean by this is that when I call the method from my browser and not the js file it shows a blank html page with the JSON output of the object. I would like to hide it from the browser view.
Browser is actually the one who is sending the request for you. It adds request headers, compression etc on your behalf so their is no way you can hide your payload from browser. That's the way web work, if you want some essential details not to be read when response packets travel either encode-decode or encrypt-decrypt your response and use HTTPS.

Django Rest Framework page doesn't show POST results in certain circumstances

I'm working on an application that uses the Django Rest Framework. For testing purposes, we occasionally use the default Django Rest Framework page for debugging or testing purposes.
Another developer recently discovered, that with one of our endpoints (that only has a POST method on it) immediately redirects without showing the last posted content of the POST call. The redirect results in an HTTP 405 (method not allowed). This behaviour is unlike most of our other endpoints - even those that only have a POST option. when they are posted to, they show the content of the POST call, as well as the text box that allows another POST.
In digging into this, I discovered that this particular endpoint was returning a response in the form of an HttpResponse object, rather than a Response object. It was also specifying the application/json content-type for the HttpResponse object.
In playing around with this, I discovered that if I switch it to use a Response object it doesn't cause the Django Rest Framework page to redirect, and does show the response on the page. However, if I specify the content_type on the Response object, the Django Rest Framework page starts redirecting again, without showing the last posted content.
In any of these situations, it is still possible to see the response by resorting to using the Chrome Developer tools and enabling "Preserve log", so that the network call history isn't cleared with the redirect, however this is less than ideal.
In changing it to use the Response instead of HttpResponse objects, it also broke one of our unit tests, as the unit test wasn't specifying the content-type header of application/json, but was expecting a JSON response. There may be other places that are also calling it without specifying the content-type header, so ideally I would like to be able to specify a content-type on the response, but still have the Django Rest Framework page show the last POSTed content.
My questions are thus:
What causes the default Django Rest Framework page to display the last posted content (as opposed to redirecting)?
Why does specifying a content-type on the Response cause the Django Rest Framework page to not display the last posted content?

what is the facebook ajax request which get the posts?

I am trying using facebook from Scrapy.
I can log in successfully. However, I can't get the posts on facebook because the posts comes from ajax calls.
I tried using firebug and check the XHR. I got this:
I tried to check the response of all those request but none of them contains the actual data of the posts.
What is the ajax request that get the posts on facebook?
Thanks in advance
Don't use the AJAX calls from your browser. Those are encrypted since Facebook uses HTTPS connections. Focus on using their API to make the calls you need to get the data you want. That's the entire purpose of their Graph API.

Fine Uploader get response before onComplete

I am having problems with IE9 to get a json as response. In the service it returns a json but in the network in IE9 I see an XML. So, the responseJSON parameter in OnComplete comes without the response.
Is there any event before OnComplete? I want to parse the XML to json in the client side when it is IE9 or older.
I am using Fine-Uploader in basic mode.
Regards,
You will need to figure out how to return JSON from your server. Fine Uploader expects a valid JSON response and this is non negotiable. There is an open feature request that will allow integrators to contribute their own response parser, but this is a relatively low priority feature and it really doesn't apply to your situation. Your best bet is to get control of your server and ensure the response is returned in the proper format.

How does ajax form submission work?

I know how to use ajax for submitting a form and all. What I am concerned about is, what is actually happening in the background when a form is submitted via ajax.
How are the values transferred? Encrypted or not? And what is the
need of specifying submission type, I mean get or post, if the URL is
not showing the form fields?
Edit: Found this on w3schools:
GET requests can be cached
GET requests remain in the browser history
GET requests can be bookmarked
GET requests should never be used when dealing with sensitive data
GET requests have length restrictions
GET requests should be used only to retrieve data
POST requests are never cached
POST requests do not remain in the browser history
POST requests cannot be bookmarked
POST requests have no restrictions on data length
How do these apply to ajax form submission?
Basically, when you Ajax-submit a form, it is doing exact same thing as what would happen when you as a user GET or POST submit a form - except that it is done in an asynchronous thread by the browser - i.e. called XMLHttpRequest.
If you submit form as a GET request, all of the form values are stitched together as parameter strings and appended to the URL (form's ACTION URL) - prefixed by a ?. This means anyone who can intercept that communication can read the submitted form data even if request is sent to a HTTPS URL. The POST method sends form data as a separate block (from the URL) and if URL is HTTPS then form data gets encrypted.
It looks like you are just starting out in the world of web development - welcome to the world of programming. I would recommend reading up on some good web development/programming books (I don't want to promote any particular book here). Amazon may help suggest few good ones under "Web Development" kind of search terms.
Also, I suggest that you read up a little on GET vs. POST by googling for it (I can only include one or two links - google will show you hundreds).
For the clear understanding & behind the scene things please refer the links given below.
http://www.jabet.com/
How does AJAX work?
Actually ajax request is same as the normal requests at the server end.
GET or POST has their own use cases. for example: GET has a limit of data transfer depending on the browsers from 1KB to 10 KB. where POST has no such limits.
For a server both AJAX & normal request both are same. so it depends on server code which method you wish to support.
ajax requests are NOT encrypted.
http://www.w3schools.com/tags/ref_httpmethods.asp
It looks like you want a very detailed answer so you can find it yourself:
Google it and read thoroughly the pages (wikipedia for example)
Read http://www.w3.org/TR/XMLHttpRequest/
Inspect the packets between your browser and the server

Resources