def json(request, *args, **kwargs):
<EOL>params = dict(list(request.GET.items()))<EOL>callback = params.pop('<STR_LIT>', None)<EOL>url = params.pop('<STR_LIT:url>', None)<EOL>if not url:<EOL><INDENT>return HttpResponseBadRequest('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>provider = oembed.site.provider_for_url(url)<EOL>if not provider.provides:<EOL><INDENT>raise OEmbedMissingEndpoint()<EOL><DEDENT><DEDENT>except OEmbedMissingEndpoint:<EOL><INDENT>raise Http404('<STR_LIT>' % url)<EOL><DEDENT>query = dict([(smart_str(k), smart_str(v)) for k, v in list(params.items()) if v])<EOL>try:<EOL><INDENT>resource = oembed.site.embed(url, **query)<EOL><DEDENT>except OEmbedException as e:<EOL><INDENT>raise Http404('<STR_LIT>' % (url, str(e)))<EOL><DEDENT>response = HttpResponse(mimetype='<STR_LIT:application/json>')<EOL>json = resource.json<EOL>if callback:<EOL><INDENT>response.write('<STR_LIT>' % (defaultfilters.force_escape(callback), json))<EOL><DEDENT>else:<EOL><INDENT>response.write(json)<EOL><DEDENT>return response<EOL>
The oembed endpoint, or the url to which requests for metadata are passed.
Third parties will want to access this view with URLs for your site's
content and be returned OEmbed metadata.