getting oEmbed to work on my non-WordPress (static) website - oembed

I have a test page setup with several "oembed"-style links in different formats because I was trying to see what worked:
http://dev2.ohlone.edu/people/clambert/testoembed.html
None of them work. I have searched and searched Google and found nothing to indicate that I have to include a javascript file or anything else on the HTML page.
The server is running Apache on MS Windows Server. I do not manage the server and am unfamiliar with its setup.
This is a static web page - i.e., not generated using WordPress or any other CMS.
What am I missing?
Thank you,
-Cheryl Lambert
Web Designer, Ohlone College

You have added links to oembed provider links in your html. To unfurl it and make visible the content in your html all you have to do is
Invoke oEmbed api which you have added as a XML http request
you should do some thing like this
Then you could get response something like this
<oembed>
<type>photo</type>
<flickr_type>photo</flickr_type>
<title>Bacon Lollys</title>
<author_name>‮‭‬bees‬</author_name>
<author_url>https://www.flickr.com/photos/bees/</author_url>
<width>1024</width>
<height>768</height>
<url>
https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_b.jpg
</url>
<web_page>https://www.flickr.com/photos/bees/2362225867/</web_page>
<thumbnail_url>
https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_q.jpg
</thumbnail_url>
<thumbnail_width>150</thumbnail_width>
<thumbnail_height>150</thumbnail_height>
<web_page_short_url>https://flic.kr/p/4AK2sc</web_page_short_url>
<license>All Rights Reserved</license>
<license_id>0</license_id>
<html>
<a data-flickr-embed="true" href="https://www.flickr.com/photos/bees/2362225867/" title="Bacon Lollys by ‮‭‬bees‬, on Flickr"><img src="https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_b.jpg" width="1024" height="768" alt="Bacon Lollys"></a><script async src="https://embedr.flickr.com/assets/client-code.js" charset="utf-8"></script>
</html>
<version>1.0</version>
<cache_age>3600</cache_age>
<provider_name>Flickr</provider_name>
<provider_url>https://www.flickr.com/</provider_url>
</oembed>
Parse the response content and construct a div content which could contain
File name
Author name
Provider name
Description or
Embed video content
And finally add the content to your HTML page.

Related

Post method of CFHTTP is not working in coldfusion 10 however get works

I have a page in Coldfusion 10 which uses the below code :
<cfhttp url ="http://mysite.am.com/index.cfm" resolveURL="yes" throwOnError="no" method="post">
<cfhttpparam type ="formfield" name="fuseaction" value="searchOrders">
<cfhttpparam type ="formfield" name="cookieValue" value="#cookie.Mycookie#">
</cfhttp>
<cfoutput>left(trim(#cfhttp.filecontent#),4)</cfoutput>
second called page has below code:
<form>
<cfif isDefined("attributes.cookieValue")>
TRUE
<cfelse>
FALSE
</cfif>
</form>
Nothing is returned on the calling page. However if I pass the url (http://mysite.am.com/index.cfm?fuseaction=searchOrders&Mycookie=C176060) directly in the browser it works and displays TRUE. There is no error on the page. The page has nothing returned.
I'd debug this by checking the Browser's Network (Chrome Developer Toolbar / Firebug) to see if your CFHTTP is posting correctly and what it's posting and see what the response is. Also instead of using the attributes scope maybe just use form scope to see if it's coming through.
Sorry, not enough rep to post a comment :(
In the second page you should access through 'FORM' scope. You have given 'FORMFIELD' in the first page.
Don't use attribute scope for fetching variables.

Large number of likes but now realise it is to an invalid url

My site at www.kruaklaibaan.com (yes I know it's hideous) currently has 3.7 million likes but while working to build a proper site that doesn't use some flowery phpBB monstrosity I noticed that all those likes are registered against an invalid URL that doesn't actually link back to my site's URL at all. Instead the likes have all been registered against a URL-encoded version:
www.kruaklaibaan.com%2Fviewtopic.php%3Ff%3D42%26t%3D370
This is obviously incorrect. Since I already have so many likes I was hoping to either get those likes updated to the correct URL or get them to just point to the base url of www.kruaklaibaan.com
The correct url they SHOULD have been registered against is (not url-encoded):
www.kruaklaibaan.com/viewtopic.php?f=42&t=370
Is there someone at Facebook I can discuss this with? 3.7m likes is a little too many to start over with without a lot of heartache. It took 2 years to build those up.
Short of getting someone at Facebook to update the URL, the only option within your control that I could think of that would work is to create a custom 404 error page. I have tested such a page with your URL and the following works.
First you need to set the Apache directive for ErrorDocument (or equivalent in another server).
ErrorDocument 404 /path/to/404.php
This will cause any 404 pages to hit the script, which in turn will do the necessary check and redirect if appropriate.
I tested the following script and it works perfectly.
<?php
if ( $_SERVER['REQUEST_URI'] == '/%2Fviewtopic.php%3Ff%3D42%26t%3D370' ) {
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: /viewtopic.php?f=42&t=370");
exit();
} else {
header('HTTP/1.0 404 Not Found');
}
?><html><body>
<h1>HTTP 404 Not Found</h1>
<?php echo $_SERVER['REQUEST_URI']; ?>
</body></html>
This is a semi-dirty way of achieving this, however I tried several variations in Apache2.2 using mod_alias's Redirect and mod_rewrite's RewriteRule, neither of which I have been able to get working with a URL containing percent encoded chars. I suspect that with nginx you may have better success at a more graceful way to handle this in the server.

Unknown GET Request after POST Request

I have an a.shtml page and a form on it. When i submit the form with POST i call a.cgi and redirect the page b.shtml from the cgi with META. But i saw on access.log that a.cgi executes two times. It causes some problems. Why it is called twice and the second one is with GET and how can i avoid this? It is only occurs on Chrome. IE,Firefox is OK
my form:
<form method="post" action="cgi-bin/a.cgi"> ....</form>
meta inside the cgi:
printf("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"3;url='/b.shtml'\ "/>");
access log:
..POST /cgi-bin/a.cgi HTTP/1.1|Host: xxx.xxx.xxx.xxx|Connection: keep-alive|Content-Length: 42|Cache-Control: max-age=0|Origin: .....
..GET /cgi-bin/a.cgi HTTP/1.1|Host: xxx.xxx.xxx.xxx|Connection: keep-alive|User-Agent: Mozilla/5.0 (Windows NT
It sounds like you want to trigger a resubmission of an HTTP POST using a html meta refresh element.
I don't know if this is possible or reliable. Hopefully these terms help you with googling at least.
You may wish to look into using sessions instead.
Edit2:
I found this SO question:
"POST-requesting a location sending Refresh header makes Firefox create GET request but still hold POST data"

Fault calling SAP web service with generated SUDZC proxy: CX_ST_MATCH_ELEMENT

Trying to call a SAP SOAP Web Service from a generated sudzc app shows errors I don't know:
SudzCExamples[5192:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:sap-
com:document:sap:soap:functions:mc-style"><soap:Body><ZComUrlGetrecords>
<IYear>2012</IYear></ZComUrlGetrecords></soap:Body></soap:Envelope>
SudzCExamples[5192:f803] <soap-env:Envelope xmlns:soap-
env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header></soap-env:Header><soap-
env:Body><soap-env:Fault><faultcode>soap-env:Server</faultcode><faultstring
xml:lang="en">CX_ST_MATCH_ELEMENT:XSLT exception.System expected element
'IYear'</faultstring><detail><ns:SystemFault
xmlns:ns="http://www.sap.com/webas/710/soap/runtime/abap/fault/system/">
<Host>undefined</Host><Component>APPL</Component><ChainedException>
<Exception_Name>CX_SOAP_CORE</Exception_Name><Exception_Text>CX_ST_MATCH_ELEMENT:XSLT
exception.System expected element 'IYear'</Exception_Text></ChainedException>
<ChainedException><Exception_Name>CX_SXMLP</Exception_Name><Exception_Text>XSLT
exception</Exception_Text></ChainedException><ChainedException>
<Exception_Name>CX_ST_MATCH_ELEMENT</Exception_Name><Exception_Text>System expected
element 'IYear': Main Program:/1BCDWB/WSS825E06E4DEC40F9171D|
Program:/1BCDWB/WSS825E06E4DEC40F9171D| Line: 18| Valid:X</Exception_Text>
</ChainedException></ns:SystemFault></detail></soap-env:Fault></soap-env:Body></soap-
env:Envelope>
2012-03-11 20:09:30.631 SudzCExamples[5192:f803] soap-env:Server CX_ST_MATCH_ELEMENT:XSLT
exception.System expected element 'IYear'
(null)
The strange thing is that it seems as if the request has the IYear element. Can someone tell me where to search the problem?
I ran into this same problem yesterday and discovered the solution after some experimentation. First thing I did was use my SoapUI client to make the request successfully. SoapUI comes with a free trial and even if you do not use the free trial you can still use it to make accesses to the web service without registering it. I used the xml from the successful request I made to compare against the request that SudzC was making. They differ in several ways, and the way that SudzC forms the request is not sufficient.
My suggestion to you is to compare the two requests and change SudzC's request to match the SoapUI request. You can do this by editing the Soap source code that SudzC gives to you, this source code is found particularly in the Soap.m file in the createEnvelope function.
Also, if your requests have an empty header SudzC does not include the header part of the request. Hard code in an empty header after the namespace portion of the envelope. Doing all this fixed this exact issue for me.

ASP.net MVC favicon doesn't show up

I need some help with showing the favicon on my site while using ASP.NET MVC.
The problem in short is that whenever a request is made for
http://example.com/favicon.ico OR
http://example.com/Content/favicon.ico
the request never gets served. Firefox says :
Content Encoding Error - The page you
are trying to view cannot be shown
because it uses an invalid or
unsupported form of compression.
I have tried ignoring the route using the following ignore route strategies, obviously not all at the same time ;-)
routes.Add(new Route("favicon.ico", new StopRoutingHandler()));
routes.IgnoreRoute("{*favicon}", new { favicon = #"(.*/)?favicon.ico(/.*)?" });
routes.IgnoreRoute("Content/{file}", new { file = #".*" });
I can confirm that it is ignoring the route because I subclassed the controller factory and it does not call CreateController
The kicker is this, I also have a png version of the file and it does get served. I have also checked it with fiddler and whenever I try to request the ico directly through url I get a pop-up that says something like this:
The magic number in GZip header is not
correct. Make sure you are passing in
a GZip stream.
So it seems that somehow IIS is trying to send it back compressed?
How do I stop this behavior/make it work?
Any insights?
UPDATE:
I figured it out, the web.config had a custom httpmodule that dealt with serving physical files and it was trying to compress the file output. That doesn't work when you have image files. :-)
Why are you adding it as a route??
Just add this to your master page header:
<link rel="shortcut icon" media="all" type="image/x-icon" href="<%= Url.Content("~/favicon.ico") %>" />

Resources