Layout as a Service REST API is not working for the multilingual pages - dotcms

We are using the dotCMS's Layout as a service REST API to display page at the REACT framework. We have added multilingual pages in the dotCMS. When we are accessing those pages using API (LaaS) then we are getting English language page json.
There is no way to get page's json for other languages.
https://dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas

Yes, you can do it, you just need to pass the language_id param to the endpoint, here is an example of a page I just created in the demo:
English: https://demo.dotcms.com/api/v1/page/render/test-page/i-m-a-page?language_id=1
Spanish: https://demo.dotcms.com/api/v1/page/render/test-page/i-m-a-page?language_id=2
In both you can check the response in page.title you will see:
English: "I'm a page"
Spanish: "Soy una pagina"
Ans also the rendered property will give you the full html in the requested language version.

Related

Sitecore Web Form for Marketers - create a cookie

This is a two part question.
Using Web Forms for Marketers 2.3:
Is it possible to have a cookie be created on successful submission?
Without actually exporting the ascx file, would like to keep it in Sitecore.
Second question, would it be better to have a content editor choose which item has the form or would it be better/easier to have a dropdown to pick which form is needed and then have the code determine which form to show.
Thank for any insight!!!
For the First question,
If you have Sitecore DMS, on a successful submission there is an event, and a Goal maybe you can use that, insteed of a cookie.
See https://doc.sitecore.net/sitecore%20experience%20platform/personalization/walkthrough%20personalizing%20components for using it with personalization rules the picturs are for Sitecore 8 but basically the same for Sitecore 6.5+
Programmatically you can use the Analytics API, see https://sdn.sitecore.net/upload/sitecore6/65/engagement_analytics_api_cookbook_sc65-a4.pdf for Sitecore 6. The API has changed considerably with Sitecore 7.5.
An alternative is to set the cookie on the Success page.
you can have a Success page, or a Success message in WFFM. for a message use something like this:
Thanks <script>document.cookie="formsuccess=ok";</script>

Retrieving Tags from web pages

I am working on a (Browser Helper Object) plugin for Internet Explorer using C++. I intend to use IHTMLDocument2 interface to fetch all tags from a Web page, identify phone numbers and add a hyperlink next to it.
Could someone provide me with a basic sample code for retrieving all tags (Using IHTMLDocument2)from the web page or guide me to some webpage ?
UPDATE
I have an alternative approach of adding a javascript to the page using the bho. the javascript could be used to add hyperlinks besides the phone numbers. Is this a better approach ?
Thanks

Is QtWebkit needed to fetch data from websites that need login?

As the title implies,
I need to fetch data from certain website which need logins to use.
The login procedure might need cookies, or sessions.
Do I need QtWebkit, or can I get away with just QNetworkAccessManager?
I have no experience at both, and will start learning as I go.
So please save me a bit of time of comparing both ^^
Thank you in advance,
Evan
Edit: Having read some related answers,
I'll add some clarifications:
The website in concern does not have an API. So I will need to scrape web elements for the data myself.
Can I do that with just QNetworkAccessManager?
No, in most cases you don't need a full simulated web browser. In most cases, just performing the same web requests like a web browser would do is enough.
Try to record the web requests in your browser, using a plugin like "HTTP Live Headers" or "Firebug" in Firefox. I think Chrome provides a similar tool out of the box. These tools record the GET and POST requests done by the website when you send a form in the webpage.
Another option is to inspect the HTML code of the login page. Find the <form> tag and its fields. Put them together in a GET / POST request in your application to simulate the same form.
Remember that some pages use randomized "tokens" in their forms, some set the tokens as cookies. In such cases, you need to request the login page itself in your application first (before sending the filled in form). Both QWebView and QNetworkAccessManager have cookie support.
To sum things up, I think QWebView provides a far more elegant way to simulate user interaction with a web page. The manual way is, however, more "lightweight", as you don't need Webkit and your application might be faster (because only the HTML page is loaded, without any linked resources like images, CSS, javascript files).
QWebView as class name states is a view, so it views something (in this case web pages). If you don't need to display loaded page, then you don't need a view. QNetworkAccessManager may do the work, but you need some knowledge about HTTP protocol, and also anything about target site: how does it hande logins, what type of request you have to send to login etc.

Does Facebook support Hash Bang #! Ajax Crawlable Urls?

Does Facebook support Google's ajax crawling specification and, if so, what do you need to do to implement it?
I am trying to get the Facebook "Like" button to work with AJAX crawlable urls as defined here: code.google.com/web/ajaxcrawling/docs/specification.html
I have this url which I can go to directly and it loads. Note the "#!" in the url:
http://www.idkshouldi.com/?#!idkDetails_idkKey=agppZGtzaG91bGRpcmMLEiljb21faWRrc2hvdWxkaV93ZWJfc2VydmVyX2dhZV9vYmpfSWRrVXNlciIDamltDAsSKWNvbV9pZGtzaG91bGRpX3dlYl9zZXJ2ZXJfZ2FlX29ial9JZGtJdGVtGN6kBgw
When I "Like" this page it should crawl this "escaped fragment" url:
http://www.idkshouldi.com/?_escaped_fragment_=idkDetails_idkKey=agppZGtzaG91bGRpcmMLEiljb21faWRrc2hvdWxkaV93ZWJfc2VydmVyX2dhZV9vYmpfSWRrVXNlciIDamltDAsSKWNvbV9pZGtzaG91bGRpX3dlYl9zZXJ2ZXJfZ2FlX29ial9JZGtJdGVtGN6kBgw
Why won't it crawl this page? The Facebook linter is not properly crawling my page. If one uses the Facebook linter tool here: developers.facebook.com/tools/debug
It won't properly crawl an AJAX enabled URL with the "#!" in it. This is Google's specification. What Facebook's lint crawler needs to do is to replace the "#!" with "_escaped_fragment_". It doesn't appear to do that with my AJAX enabled links.
This is also a big problem for me, but unfortunately it appears Facebook does not support this Google URL notation. Facebook's crawler/parser does not translate from hash bang (#!) to an _escaped_fragment_ format URL.
Like you I have tested my page on Facebook's URL linter and it only picks up static Open Graph tags within the dynamic original page, rather than the page-specific Open Graph tags in the _escaped_fragment_ server-side variant of my page. Unfortunately, this means that Facebook sees my Open Graph tags as site-specific, rather than page specific.
It is rather an irony that this appears to be unsupported as Facebook uses this approach itself to allow Google's crawlers to pick up Facebook pages.
One potential workaround, that may help you a little bit, is:
1) Use your _escaped_fragment_ page version in Facebook links
2) Add an automatic redirect to your _escaped_fragment_ variant to the proper version.
This should mean that Facebook will pick up the proper meta tags, and the user will click the link and end up on the correct page. The downside of this approach is that the user has to know the rather ugly _escaped_fragment_ URL. In other words, it will probably only be you that knows it, unless you add some sort of 'generate shareable link' button to your page.
It is surely only a matter of time before Facebook adds support for this as single-page hash bang sites are only going to become more prevalent.

Distinguish between facebook app iframe and genuine site visit (django app)

I'm trying to distinguish between a web request coming from inside the iframe of my app in facebook vs a regular web visit. That way I can deliver the correct layout.
I had set a session variable when the first iframe request comes into my server (facebook sends a POST param called signed_request to your default canvas url), but then if the user actually visits me website after (outside of facebook) they get iframe layout delivered instead of what my site should look like.
I've looked through all the META info that come in with the iframe request and I dont see anything that would allow me to distinguish the two.
Any help would be much appreciated.
UPDATE: I'm using AppEngine as my application host
The easiest way is to make a unique url for access from Facebook, e.g. if your website is www.site.com then set up either fb.site.com or www.site.com/fb on your server and point it to the same place as www.site.com (and of course set your Facebook app settings to use the alternate url). Then your server code can easily check the accessing url to determine whether to format for Facebook or standalone website.
Another approach is to combine a session variable on the server-side with some javascript on the client-side. You can set a session variable when you receive the signed_request parameter, and then check it on each page load. As long as the session variable is set, you output iframe format and add a bit of javascript code to each page. The javascript checks to make sure the page is still in an iframe using something like if (window.self!=window.top) { //inside iframe }. If not inside an iframe it means the session variable is now stale, so the js jumps to some url that tells the server to clear it and then re-display the page in regular layout.