I am struggling to insert a link with a FB Share.
The link is calling a JS. JS opens a popup and my image is missing.
I have 2 options:
1. sharer.php
2. API?
1: THIS IS NOT SHOWING MY PHOTO!!!
function fbs_click(id, photo) {
var adv_url = encodeURIComponent("https://www.bikesquare.com.au/product/detail?advertiseId=" + "e77180f8439fe2810143be28c40e000e");
var photo_url = encodeURIComponent("https://www.bikesquare.com.au/resources/IMG_0554.JPG"); //THIS IS A REAL IMAGE - ONLY FOR TEST!!!
var new_url="https://www.facebook.com/sharer.php?s=100";
new_url += "&p[url]=" + adv_url;
new_url +="&p[images][0]=" + photo_url;
new_url +="&p[summary]=TEST";
new_url +="&p[title]=TITLE";
window.open(new_url, 'Share on FaceBook', 'left=20,top=20,width=550,height=400,toolbar=0,menubar=0,scrollbars=0,location=0,resizable=1');
return false; //FOR TEST ONLY
}
2: THIS IS SHOWING MY PHOTO, BUT ONLY I CAN SHARE!! Other FB accounts CANNOT
var url = 'https://www.facebook.com/dialog/feed?app_id=[MY SECRET API ID]&link=' +
encodeURIComponent('https://www.bikesquare.com.au/product/detail? advertiseId=') + id +
'&picture=' + encodeURIComponent(photo_url) +
'&name=' + encodeURIComponent('BikeSquare Advertise') +
'&redirect_uri=' + encodeURIComponent('https://www.bikesquare.com.au/');
window.open(url, 'Share on FaceBook', 'left=20,top=20,width=550,height=400,toolbar=0,menubar=0,scrollbars=0,location=0,resizable=1');
As you can see ladies and gentlemen, I have 2 options. Opt 1 not showing photo. Opt 2 requires a APP ID from FB DEV but only I can share it (photo looks good). Other accounts cannot...
What am I missing here?
started to use FB API method and discovered that was on DEV MODE not on public mode...
Related
I have been attempting to code a button into my adobe PDF form using an article from quora. The goal is to click a button and it opens an email box with the "to", "subject line", "body" and the "PDF" attaching to the email without having to save the pdf somewhere locally on the clients computer.
These are the three different codes I have found and attempted to use. No matter what I do, I end up getting an "Unterminated String Literal" on line 3 where the body field starts. I have tried adding/removing everything I can think of. ;"'{{:.
Please help if you can! See code below.
var customSubject = this.getField("MyTextField").value;
var mailtoUrl = "mailto:email#email.com?subject=" + Information Form;
this.submitForm({Thank you for your considerate attention to the attached pdf. Let me know if you need anything.; further.
cURL: mailtoUrl, cSubmitAs: "PDF" });
var customSubject = this.getField("MyTextField").value;
var mailtoUrl = "mailto:email#email.com=" + Information Form;
this.submitForm({Thank you for your considerate attention to the attached pdf. Let me know if you need anything.
cURL: mailtoUrl, bPDF:true});
var cToAddr = "email#email.comm"
var cSubLine = "Information Form - " + this.getField(No1LastName) + ", " + this.getField(No2LastName) + "
var cBody = "Please find the attached Information Form. Thank you for your considerate attention to the attached."
this.mailDoc({bUI: true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody});
I found that declaring a variable for the email portion worked. I was able to include custom to, cc, subject, and body, as well as attaching the PDF.
var customREmail = this.getField("ReqEmail").value;
var customAEmail = this.getField("AgyEmail").value;
var customAgency = this.getField("Agency").value;
var customLName = this.getField("Lease").value;
var customBAddr = this.getField("BldgAddr").value;
var customBCity = this.getField("BldgCity").value;
var mailtoUrl =
"mailto:XXX#XXX.XXX?cc=" +
customREmail +
"; " +
customAEmail +
"&subject=Compliance%20Request: " +
customAgency +
", " +
customLName +
" - " +
customBAddr +
", " +
customBCity +
"&body=Please review the attached request.%0A%0AThank you,%0A%0A";
this.submitForm({
cURL:mailtoUrl, cSubmitAs:"PDF", bPDF:true
});
I'm trying to read an element from a dynamic website, but am facing a weird (at least to my poor understanding) issue.
Below is a snapshot from the Developer Tool from Chrome
I'm trying to read the innertText of the highlighted line (please note this is a dynamic website, so the "li id's"change).
When I'm firing document.querySelector("#\\31 60698c8-9d6c-492b-acf8-13b82467f873 > div > span.room-display-message-message") in the DevTools Console while highlighting the line as in the above snapshot the innerText is returned, but when I'm moving my selection higher up in the tree, e.g. to "iframe class = "trollbox-iframe" and then running the same script it returns "null".
This behavior also pops up when making the script more random like document.querySelector("* > div > span.room-display-message-message")
Am I getting crazy or is this normal and should I take another approach?
I'm asking this because I'm developing a tool in C# using a CEFSharp Chromium webbrowser to read contents of this website, but that's not relevant at the nmoment
OK, itr took me a few days, but I finally got what I wanted. For those interested here's my solution:
First thing is to add a CefSharp.WinForms.CefSettings to your browser element, being "--disable-web-security"
For calling this trollbox iframe I'm using below Javascript (I know it can be simplified, but hey...it works
var script2 = "function foo(){" +
"var re = /[^-a - zA - Z!, '?\s]/g;" +
"var messages = [];" +
"doc = document.getElementsByClassName('trollbox-container open')[0];" +
"ifrm = doc.getElementsByTagName('iframe')[0];" +
"docInside = ifrm.contentDocument ? ifrm.contentDocument : ifrm.contentWindow.document;" +
"docTag = docInside.getElementsByClassName('content small')[0];" +
"msgList = docTag.getElementsByClassName('message-list')[0];" +
"msgList_sender = msgList.getElementsByClassName('room-display-message-sender');" +
"msgList_message = msgList.getElementsByClassName('room-display-message-message');" +
"for (var i = 0; i < msgList_sender.length; i++)" +
" {" +
" var sender = msgList_sender[i].innerText;" +
" var message = msgList_message[i].innerText;" +
" messages.push(sender + ': ' + message);" +
" }" +
"return messages;" +
"}" +
"foo();";
Finally running this code
JavascriptResponse response = await browser1.EvaluateScriptAsync(script2);
returns me the information from the trollbox I wanted
I know that plenty of similar questions can be found here but none of them could help me with my problem.
What the client wants: click on a button, then open a new window with given parameters and show a view with dynamic data loaded from database.
What I have done so far:
I have a view with links, not buttons:
<a th:href="#{/report/reportPrintView(al=false, mlVersion=${report.version}, sv=true, id=${report.orderId})}" target="_blank">Protokoll</a>
<a th:href="#{/report/reportPrintView(al=true, mlVersion=${report.version}, sv=false, id=${report.orderId})}" target="_blank">Airline</a>
and a controller which is called by the GET request:
#GetMapping("/report/reportPrintView")
public String showReportPrint(#RequestParam("al") boolean al, #RequestParam("mlVersion") String mlVersion, #RequestParam("sv") boolean sv, #RequestParam("id") String id, Model model) {
........ do some magic .......
return "/report/reportPrintView";
}
The view is displayed in a new browser tab and works as expected, but as said before, the client wants a new window.
To get a solution for the clients wishes I tried something like this:
function openWin(id, mlVersion, al, sv) {
var url = "/report/reportPrintView.html?al=" + al + "&mlVersion=" + mlVersion + "&sv=" + sv + "&id=" + id;
ReportPrintPreview = window.open("about:blank", "ReportPrintPreview", "width=666,height=700left=250,top=50,dependent=yes,menubar=no,status=no,resizable=yes,toolbar=no,scrollbars=yes");
ReportPrintPreview.location.href = url;
ReportPrintPreview.focus();
return false;
}
.
.
.
<button th:onclick="'openWin(\'' + ${report.orderId} + '\', \'' + ${report.version} + '\', false, true)'">Protokoll</button>
<button th:onclick="'openWin(\'' + ${report.orderId} + '\', \'' + ${report.version} + '\', true, false)'">Airline</button>
What happens here is that a new window is opened with a 404 error and the web page with the button shows a 400 error. So I assume that the controller doesn't get the GET request and cannot show the view (as is a reasonable result because it's not a Thymeleaf call like #{/report/....}).
Is there any way to get this running?
This is how I would structure that.
JavaScript
function openWin(url) {
ReportPrintPreview = window.open("about:blank", "ReportPrintPreview", "width=666,height=700left=250,top=50,dependent=yes,menubar=no,status=no,resizable=yes,toolbar=no,scrollbars=yes");
ReportPrintPreview.location.href = url;
ReportPrintPreview.focus();
return false;
}
Thymeleaf
<button
th:data-url="#{/report/reportPrintView(al=false, mlVersion=${report.version}, sv=true, id=${report.orderId})}"
onclick="openWin(this.getAttribute('data-url'))">Protokoll</button>
<button
th:data-url="#{/report/reportPrintView(al=true, mlVersion=${report.version}, sv=false, id=${report.orderId})}"
onclick="openWin(this.getAttribute('data-url'))">Airline</button>
For thymeleaf it works in different way. try below.
th:target="_blank"
DISCLAIMER: I'm new to Stack Overflow and I'm not a developer.
I work in IT and we are currently trying to take all of our paper/electronic forms and turn them into Google Forms. I am currently trying to write a script (see below) that will send an email to a specific person based on one of the answers. The good news is that the script works (woot!).
The problem that I'm having is that I get 2 - 3 of the exact email when I test it. It's especially bad in with my gmail account.
If the below code looks atrocious, I'm open to suggestions! Thanks in advance for the help!!
function myFunction() {
var form = FormApp.getActiveForm()
var formResponses = form.getResponses();
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
var itemResponses = formResponse.getItemResponses();
var work = itemResponses[3];
var problem = itemResponses[2].getResponse();
var location = itemResponses[4].getResponse();
var name = itemResponses[0].getResponse()
var sheetsLink = docs.google.com/sheetid
}
if (work.getResponse() === "Food Services") {
MailApp.sendEmail('mymail#gmail.com', 'Kitchen Maintenance', name + ' has a problem with ' + problem + ' in the kitchen at ' + location + '. More information for this request can be found at: ' + sheetsLink + '.');
} else {
MailApp.sendEmail('mymail#schoolacct', 'Maintenance', name + ' has a problem with ' + problem + ' at ' + location + '. More information for this request can be found at: ' + sheetsLink + '.');
}
}
It might be easier for you to get the form responses saved in a spreadsheet then tie the apps script to the spreadsheet with an on form submit trigger. This will allow you to have a record of all form responses in the spreadsheet and if anything goes wrong, you can always recheck. On the multiple emails sent, the multiple editors is the thing to check.
I've been asked to make unofficial online streaming android application for a certain radio station.
I've experience with streaming in android for certain mp3 or whatever stream.
But I don't know the stream url to provide in mediaPlayer.setDataSource(url).
Is there any way to get the stream url from the ofiicial streaming page for ex. this radio stream?
not that hard,
if you take a look at the page source, you'll see that it uses to stream the audio via shoutcast.
this is the stream url
"StreamUrl": "http://stream.radiotime.com/listen.stream?streamIds=3244651&rti=c051HQVbfRc4FEMbKg5RRVMzRU9KUBw%2fVBZHS0dPF1VIExNzJz0CGQtRcX8OS0o0CUkYRFJDDW8LEVRxGAEOEAcQXko%2bGgwSBBZrV1pQZgQZZxkWCA4L%7e%7e%7e",
which returns a JSON like that:
{
"Streams": [
{
"StreamId": 3244651,
"Reliability": 92,
"Bandwidth": 64,
"HasPlaylist": false,
"MediaType": "MP3",
"Url": "http://mp3hdfm32.hala.jo:8132",
"Type": "Live"
}
]
}
i believe that's the url you need:
http://mp3hdfm32.hala.jo:8132
this is the station WebSite
Edited ZygD's answer for python 3.x.:
import re
import urllib.request
import string
url1 = input("Please enter a URL from Tunein Radio: ");
request = urllib.request.Request(url1);
response = urllib.request.urlopen(request);
raw_file = response.read().decode('utf-8');
API_key = re.findall(r"StreamUrl\":\"(.*?),\"",raw_file);
#print API_key;
#print "The API key is: " + API_key[0];
request2 = urllib.request.Request(str(API_key[0]));
response2 = urllib.request.urlopen(request2);
key_content = response2.read().decode('utf-8');
raw_stream_url = re.findall(r"Url\": \"(.*?)\"",key_content);
bandwidth = re.findall(r"Bandwidth\":(.*?),", key_content);
reliability = re.findall(r"lity\":(.*?),", key_content);
isPlaylist = re.findall(r"HasPlaylist\":(.*?),",key_content);
codec = re.findall(r"MediaType\": \"(.*?)\",", key_content);
tipe = re.findall(r"Type\": \"(.*?)\"", key_content);
total = 0
for element in raw_stream_url:
total = total + 1
i = 0
print ("I found " + str(total) + " streams.");
for element in raw_stream_url:
print ("Stream #" + str(i + 1));
print ("Stream stats:");
print ("Bandwidth: " + str(bandwidth[i]) + " kilobytes per second.");
print ("Reliability: " + str(reliability[i]) + "%");
print ("HasPlaylist: " + str(isPlaylist[i]));
print ("Stream codec: " + str(codec[i]));
print ("This audio stream is " + tipe[i].lower());
print ("Pure streaming URL: " + str(raw_stream_url[i]));
i = i + 1
input("Press enter to close")
The provided answers didn't work for me. I'm adding another answer because this is where I ended up when searching for radio stream urls.
Radio Browser is a searchable site with streaming urls for radio stations around the world:
http://www.radio-browser.info/
Search for a station like FIP, Pinguin Radio or Radio Paradise, then click the save button, which downloads a PLS file that you can open in your radioplayer (Rhythmbox), or you open the file in a text editor and copy the URL to add in Goodvibes.
Shahar's answer was really helpful, but I found it quite tedious to do this all myself, so I made a nifty little Python program:
import re
import urllib2
import string
url1 = raw_input("Please enter a URL from Tunein Radio: ");
open_file = urllib2.urlopen(url1);
raw_file = open_file.read();
API_key = re.findall(r"StreamUrl\":\"(.*?),",raw_file);
#print API_key;
#print "The API key is: " + API_key[0];
use_key = urllib2.urlopen(str(API_key[0]));
key_content = use_key.read();
raw_stream_url = re.findall(r"Url\": \"(.*?)\"",key_content);
bandwidth = re.findall(r"Bandwidth\":(.*?),", key_content);
reliability = re.findall(r"lity\":(.*?),", key_content);
isPlaylist = re.findall(r"HasPlaylist\":(.*?),",key_content);
codec = re.findall(r"MediaType\": \"(.*?)\",", key_content);
tipe = re.findall(r"Type\": \"(.*?)\"", key_content);
total = 0
for element in raw_stream_url:
total = total + 1
i = 0
print "I found " + str(total) + " streams.";
for element in raw_stream_url:
print "Stream #" + str(i + 1);
print "Stream stats:";
print "Bandwidth: " + str(bandwidth[i]) + " kilobytes per second."
print "Reliability: " + str(reliability[i]) + "%"
print "HasPlaylist: " + str(isPlaylist[i]) + "."
print "Stream codec: " + str(codec[i]) + "."
print "This audio stream is " + tipe[i].lower() + "."
print "Pure streaming URL: " + str(raw_stream_url[i]) + ".";
i = i + 1
raw_input("Press enter to close TMUS.")
It's basically Shahar's solution automated.
When you go to a stream url, you get offered a file. feed this file to a parser to extract the contents out of it. the file is (usually) plain text and contains the url to play.