scara / moodle-local_twittercard

This Moodle local plug-in emits a Twitter summary card for courses.
GNU General Public License v3.0
2 stars 1 forks source link

No meta tags generated when course requires login #10

Open lwilson opened 6 years ago

lwilson commented 6 years ago

The twittercard plugin works for our main site page (https://learn.tacc.utexas.edu), but it can't seem to generate cards for specific courses (I've been using https://learn.tacc.utexas.edu/course/view.php?id=10 as a test).

When I use cURL to pull the HTML, it appears that the URL resolves to an automatic redirect:

$ curl -A "Twitterbot" -v -1 "https://learn.tacc.utexas.edu/course/view.php?id=10"
*   Trying 129.114.97.176...
* Connected to learn.tacc.utexas.edu (129.114.97.176) port 443 (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* found 692 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
*        server certificate verification OK
*        server certificate status verification SKIPPED
*        common name: learn.tacc.utexas.edu (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: C=US,postalCode=78711,ST=TX,L=Austin,street=1 University Station,O=The University of Texas at Austin,OU=TACC - Texas Advanced Computing Center,CN=learn.tacc.utexas.edu
*        start date: Tue, 15 Aug 2017 00:00:00 GMT
*        expire date: Fri, 14 Aug 2020 23:59:59 GMT
*        issuer: C=US,ST=MI,L=Ann Arbor,O=Internet2,OU=InCommon,CN=InCommon RSA Server CA
*        compression: NULL
* ALPN, server accepted to use http/1.1
> GET /course/view.php?id=10 HTTP/1.1
> Host: learn.tacc.utexas.edu
> User-Agent: Twitterbot
> Accept: */*
>
< HTTP/1.1 303 See Other
< Date: Thu, 12 Oct 2017 16:46:38 GMT
< Server: Apache/2.4.18 (Ubuntu)
< Set-Cookie: MoodleSession=1m3pto2c55ha8tps6qa04savc6; path=/; secure
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< Location: https://learn.tacc.utexas.edu/login/index.php
< Content-Language: en-us
< Content-Length: 449
< Content-Type: text/html; charset=utf-8
<
<!DOCTYPE html>
<html  lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Redirect</title>
* Connection #0 to host learn.tacc.utexas.edu left intact
</head><body><div style="margin-top: 3em; margin-left:auto; margin-right:auto; text-align:center;">This page should automatically redirect. If nothing is happening please use the continue link below.<br /><a href="https://learn.tacc.utexas.edu/login/index.php">Continue</a></div></body></html>

Is there a specific way the course needs to be setup for the callbacks to work? Am I using the wrong URL perhaps?

Thanks!

scara commented 6 years ago

Hi Lucas, 303 is the HTTP status used by Moodle to redirect you to the login page: this will happen to those courses restricted to "selected" i.e enrolled users.

To let the card work, you should think about the course visibility: meta tags are there - except for bugs - but Twitter cannot access them since the course page is restricted to enrolled users i.e. it requires a valid user.

Unfortunately the course cannot be opened to Twitter unless changing some logic to mimic what already available for Google (https://docs.moodle.org/33/en/Search_engine_optimization#Moodle_settings).

HTH, Matteo

scara commented 6 years ago

Follow up: I'm still looking for a nice solution and the discussion in MDL-61586 would provide some good pointers.