Facebook open graph action returns "false" - facebook-opengraph

I'm trying to post an action to open graph but the only response I'm getting is "false".
According to the "Creating and Using Actions" portion of the API it appears that I'm doing this correctly.
Code sample below.
var url = facebook.root + 'objects/' + verb + '/' + noun + '.html';
var method = 'https://graph.facebook.com/me/joe_longstreet:' + verb + '?' + noun + '=' + url + '&distance=' + distance + '&tags=' + users + '&access_token=' + facebook.token;
FB.api(method, 'post', function(response){
if(response.error){
alert(response.error.message);
} else{
console.log(response);
var message = 'Posted to your timeline!';
alert(message);
}
});
Where verb = run, noun = route, and url = my objects page.
Specifically:
https://graph.facebook.com/me/joe_longstreet:run?route=http://joelongstreet.showoff.io/Facebook_app/objects/run/route.html&distance=&tags=1915805&access_token=ABCDE
Fake access token above. What am I doing wrong here?

Looks like you don't need to include the graph.facebook.com portion of the url. so it should just read /me/joe_longstreet:run?...

Related

Extract depthmap from Google Street View

Many posts such as this one use the REST API of Google Street View like this:
http://maps.google.com/cbk?output=xml&ll=40.7625000,-73.9741670&dm=1
However, this API does not work sometimes.
Google Street View seems does not rely on that REST API, and it may store the depthmap in this meta-file:
https://www.google.com/maps/photometa/v1?authuser=0&hl=en&gl=us&pb=!1m4!1smaps_sv.tactile!11m2!2m1!1b1!2m2!1sen!2sus!3m3!1m2!1e2!2sG2__WfQLZTzrsr7FP1wUyQ!4m57!1e1!1e2!1e3!1e4!1e5!1e6!1e8!1e12!2m1!1e1!4m1!1i48!5m1!1e1!5m1!1e2!6m1!1e1!6m1!1e2!9m36!1m3!1e2!2b1!3e2!1m3!1e2!2b0!3e3!1m3!1e3!2b1!3e2!1m3!1e3!2b0!3e3!1m3!1e8!2b0!3e3!1m3!1e1!2b0!3e3!1m3!1e4!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e10!2b0!3e3
But I do not know how to extract depthmap from it. The method using Base64 in this post of Convert depth map (base64) of google street view to image does not work because the encoded string are very different.
Could anyone can get me some ideas? Thanks very much!
Here are some Python code lines to get the meta-file from Google Street View:
def getPanoJS_frm_lonlat(lon, lat):
url = "https://maps.googleapis.com/maps/api/js/GeoPhotoService.SingleImageSearch?pb=!1m5!1sapiv3!5sUS!11m2!1m1!1b0!2m4!1m2!3d{0:}!4d{1:}!2d50!3m10!2m2!1sen!2sGB!9m1!1e2!11m4!1m3!1e2!2b1!3e2!4m10!1e1!1e2!1e3!1e4!1e8!1e6!5m1!1e2!6m1!1e2&callback=_xdc_._v2mub5"
url = url.format(lat, lon)
return requests.get(url, proxies=None)
lon = -74.2249174
lat = 40.7040015
resp = getPanoJS_frm_lonlat(lon, lat)
line = resp.text.replace("/**/_xdc_._v2mub5 && _xdc_._v2mub5( ", "")[:-2]
# print(line)
jdata = json.loads(line)
print("This part may be the depthmap:")
print(jdata[1][5][0][5][3][2])
A part of the encoded depthmap in the metafile(not quite sure, and the entire string is too long to post here, please using the code above the download the meta-file):
Q0RrQUFBSUFBUWdCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUURUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkFRRUJBUUVCQVFFQkF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MzJRV2gtSDBJUjc2VkJUOFVlUWg3RkZFS3ViUUpERFlzalFvYzJJRUpTUTB0Q1RCd2dRbEhJY2tMV3RSOUNNVktiUVRGcVBNS1dIZVpCb2ZZOXdpQmFRRUowNTBIQ0Jud1pRcDV6UU1MNml0Q18wWWFjd3V6RG5FSTNFd25EZUNZc1FlODhQTUl1dThDX2tFLUt3dTF4RDhETVBzUEM0aGhCd241Z0lrSThfSG9fOTRRMFFwOExKa0ZoZUI1QzE3OTN3T3VORkVMSEQ1akJRZnM2d2c=
I recently came across this problem too and I decided to dig into it with the help of a friend.
I found the GSVPanoDepth.js library that hadn't been updated in a while but still had the fundamentals of decoding the data and parsing it. It was all pretty much the same except the url has changed and the structure of the data a bit too. I forked the repo and updated it to work with the new url and structure - https://github.com/sidequestlegend/GSVPanoDepth.js
// This url no longer works
// url = "http://maps.google.com/cbk?output=json&cb_client=maps_sv&v=4&dm=1&pm=1&ph=1&hl=en&panoid=" + panoId;
url = "https://www.google.com/maps/photometa/v1?authuser=0&hl=en&gl=uk&pb=!1m4!1smaps_sv.tactile!11m2!2m1!1b1!2m2!1sen!2suk!3m3!1m2!1e2!2s" +
panoId +
"!4m57!1e1!1e2!1e3!1e4!1e5!1e6!1e8!1e12!2m1!1e1!4m1!1i48!5m1!1e1!5m1!1e2!6m1!1e1!6m1!1e2!9m36!1m3!1e2!2b1!3e2!1m3!1e2!2b0!3e3!1m3!1e3!2b1!3e2!1m3!1e3!2b0!3e3!1m3!1e8!2b0!3e3!1m3!1e1!2b0!3e3!1m3!1e4!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e10!2b0!3e3"
fetch(url)
.then(res=>res.text())
.then(res=>JSON.parse(res.substr(4)))
.then(res=>res[1][0][5][0][5][1][2])
.then(res=>{
console.log(res);
return res;
})
.then(dm => {
var decoded, depthMap;
try {
decoded = self.decode(dm);
depthMap = self.parse(decoded);
} catch(e) {
console.error("Error loading depth map for pano " + panoId + "\n" + e.message + "\nAt " + e.filename + "(" + e.lineNumber + ")");
depthMap = self.createEmptyDepthMap();
}
if(self.onDepthLoad) {
self.depthMap = depthMap;
self.onDepthLoad();
}
})
.catch(e=>{
console.error("Request failed: " + url + "\n" + e);
var depthMap = self.createEmptyDepthMap();
if(self.onDepthLoad) {
self.depthMap = depthMap;
self.onDepthLoad();
}
});

fetching multiple images from url of xml response in xamarin forms

Can anyone guide me how to load images through image_url tags in my image control named BOOK_URL under a loop? i have fetched other book info under similar_books tag of each book tag but unable to fetch images of all book tags in my image control.
My code looks like this.
var xdoc = XDocument.Load("https://www.goodreads.com/book/title.xml?key=Uxb0zPb86N4STVy2ECWYA&title=" + title.Text);
IEnumerable<XElement> allElements =
xdoc.Descendants("similar_books").Descendants("book");
foreach (XElement result in allElements)
{
BOOK_URL.Source = BOOK_URL.Source + "\n"+
ImageSource.FromUri(new Uri(result.Element("image_url").Value)) ;
search.Text = search.Text + "\n" +
" Book Name: " + result.Element("title").Value + "\n" +
" ISBN: " + result.Element("isbn").Value + "\n" +
"Average Ratings: " + result.Element("average_rating").Value + "\n";
}
}
Also my url of xml response look like this:
https://www.goodreads.com/book/title.xml?key=Uxb0zPb86N4STVy2ECWYA&title=DUNE
i am getting all info except for images. Please help me to fetch all images of all book tags as i have fetched other book info rather than images.
this is garbage and should not even compile
BOOK_URL.Source = BOOK_URL.Source + "\n"+
ImageSource.FromUri(new Uri(result.Element("image_url").Value));
assuming that BOOK_URL is an Image control, you want to do
BOOK_URL.Source = ImageSource.FromUri(new Uri(result.Element("image_url").Value));
note that if you have multiple image urls, only the last one in the loop will be assigned
if you have two image controls, you could do this
IEnumerable<XElement> images = xdoc.Descendants("similar_books").
Descendants("book").
Descendants("image_url");
image1.Source = ImageSource.FromUri(new Uri(images[0].Value));
image2.Source = ImageSource.FromUri(new Uri(images[1].Value));

Change Field STatus

I have a button in a google-app-maker page, it's function is to sending Invoice by email. So once this button clicked, it will do two function.
1. Sending invoice by email.
2. Change status of EmailStatus to 'YES'.
/* var widgets = widget.parent.descendants; */
var to = "webmaster#myemail.com";
var subject = "Prepare Invoice : " + widget.datasource.item.Client_Name;
var msg = "Please Prepare Invoice for " + "\n\nClient Name : " +
widget.datasource.item.Client_Name + "\n\nService : " +
widget.datasource.item.Service + "\n\nCase : " +
widget.datasource.item.Subjects + "\n\nScope :" +
widget.datasource.item.Scope + "\n\nSubject : " +
widget.datasource.item.Subjects + "\n\nStart :" +
widget.datasource.item.Start + "\n\nInterim : " +
widget.datasource.item.Interim + "\n\nStatus :" +
widget.datasource.item.Statusx + "\n\nCA : " +
widget.datasource.item.Client_Ref + "\n\nBilling : " +
widget.datasource.item.Billing + "\n\nFee VS : " +
widget.datasource.item.Fee_VS + "\n\nFee VI" +
widget.datasource.item.Fee_VI + "\n\nNotes : " +
widget.datasource.item.Notes + "\n\nPrep Invoice : " +
widget.datasource.item.Prep_Invoice + "\n\nInvoiced : " +
widget.datasource.item.Prep_Invoice + "\n\nInvoice Number : " +
widget.datasource.item.Invoice_Number;
SendEmail(to, subject, msg);
widget.datasource.modes.create.item.EmailStatus = 'YES';
There's no problem with sending email, but for EmailStatus change to field have problem. It can not change value from NULL to 'YES'. Do you have any idea how to solved it ?
Thanks
Here is a scenario how to handle this assuming that your EmailStatus is just field in the same model/datasource as where you have all of your invoice information.
Delete this line of code:
widget.datasource.modes.create.item.EmailStatus = 'YES';
Change this line of code:
SendEmail(to, subject, message);
to:
SendEmail(to, subject, message, widget.datasource.item);
Change your client send email function to this:
function SendEmail(to, subject, message, item) {
google.script.run
.withSuccessHandler(function() {
item.EmailStatus = 'YES';
})
.withFailureHandler(function(error) {
//include a failure message popup or something here
})
.ServerSendEmailFunction(to, subject, message);
}
Hope this helps and solves your problem.
Is "EmailStatus" a field in the datasource of the widget, or is it a field in a different datasource? If it is actually a field in a different datasource/model, then you have to specify which record in that other datasource you want to connect to (in this case, the record called "Yes").
I'd recommend creating another server script function to set the status to "Yes" - here's the instructions for doing that: https://developers.google.com/appmaker/models/relations#server_script
Then call this new function in your success handler for the SendEmail function.

Apex Callout HTTP Version not supported

I am working on deleting the file from the Amazon from sfdc.
I have written the code for it when am sending the request to Amazon It through error:-
System.HttpResponse[Status=HTTP Version not supported, StatusCode=505]
kindly help me to solve this problem
How can I overcome this error to pass correct request?
Code:
Datetime expire = system.now().addDays(1);
String dateString = expire.formatGmt('yyyy-MM-dd')+'T'+ expire.formatGmt('HH:mm:ss')+'.'+expire.formatGMT('SSS')+'Z';
String stringToSign = 'DELETE\n' +
'\n' +
'\n' +
dateString + '\n' +
('https://s3.amazonaws.com/'+awsKeySet[0].Name__c+'/'+fname).replaceAll(' ', '');
stringToSign = stringToSign.replaceAll(' ', '%20');
System.debug('FINDME::stringToSign - ' + stringToSign);
Blob mac = Crypto.generateMac('HMacSHA1',Blob.valueOf(stringToSign), Blob.valueOf(+awsKeySet[0].AWS_Secret_Key__c));
stringToSign = EncodingUtil.base64Encode(mac);
//String encoded = EncodingUtil.urlEncode(stringToSign, 'UTF-8');
HttpRequest con = new HttpRequest();
con.setHeader('Authorization',+awsKeySet[0].AWS_AccessKey_Id__c+':' + stringToSign);
con.setEndPoint('https://s3.amazonaws.com/'+awsKeySet[0].Name__c+'/'+'Temporary/'+fname);
con.setHeader('Host',+awsKeySet[0].Name__c+'.s3.amazonaws.com');
//con.setHeader('Date', dateString);
con.setMethod('DELETE');
Http http = new Http();
HTTPResponse res = http.send(con);
System.debug('RES.GETBODY: ' + res.getBody() + ' RES.GETSTATUS: ' + res.getStatus() + ' CON.GETENDPT: ' + con.getEndPoint());
This kind of problem typically arises from an invalid URL in the HTTP request as can be seen in this post in Salesforce success community and this post in Salesforce StackExchange. This line here is where I would start:
con.setEndPoint('https://s3.amazonaws.com/'+awsKeySet[0].Name__c+'/'+'Temporary/'+fname);
There are references to an sobject field awsKeySet[0].Name__c and a variable fname that you resolve into your URL string.
Are you certain there are no spaces or unescaped characters in the underlying value of either of those?

Get a root domain on asp.net

how can I get only the domain, for example:
The url: http://localhost:11093/SiteA/Admin/Default.aspx
Then, I want to get only the: http://localhost:11093/SiteA/
I am using:
Path.GetFileName(Request.Url.Host)
But only get the: localhost, and trying:
Path.GetFileName(Request.Url.PathAndQuery)
But get the whole address. Thank you very much.
Try this one:
var HostAndPath = Request.Url.AbsoluteUri.Replace(Request.Uri.AbsolutePath, "")
Try something like this
Uri uri = new Uri("http://localhost:11093/SiteA/Admin/Default.aspx");
string requested = uri.Scheme + uri.SchemeDelimiter + uri.Host + ":" + uri.Port;
You can work directly on the request URI
Uri uri = Request.Url;
string requested = uri.Scheme + uri.SchemeDelimiter + uri.Host + ":" + uri.Port;
Try this...
Page.ResolveUrl("~").ToString()

Resources