Brach URL is giving "Trouble creating a URL" when tracking is disabled and trying to create a short url - branch.io

For GDPR compliance reasons, we have disabled link tracking in our Android and iOS applications and using generate Short URL method for getting the short link of the item, we want to share. But when we are calling generateShortUrl() method, it gives "Trouble creating a URL. Tracking is disabled. Requested operation cannot be completed when tracking is disabled" error and the URL that is returned does not work when shared on Facebook or an email when the user clicks on it.
Our concern is though tracking is disabled and Branch is unable to create a short URL, it shall return the working long URL at least. Please let us know if we have to do something here to make it work on our apps.

Can you please check if you set generateShortUrl like the following example codes for Android? You can also find detailed information about creating deep link
Android : https://docs.branch.io/apps/android/#create-deep-link
iOS : https://docs.branch.io/apps/ios/#create-deep-link
.
import io.branch.indexing.BranchUniversalObject;
import io.branch.referral.Branch;
import io.branch.referral.BranchError;
import io.branch.referral.util.LinkProperties;
BranchUniversalObject buo = new BranchUniversalObject();
LinkProperties lp = new LinkProperties();
buo.generateShortUrl(this, lp, new Branch.BranchLinkCreateListener() {
#Override
public void onLinkCreate(String url, BranchError error) {
if (error == null) {
Log.i("BRANCH SDK", "got my Branch link to share: " + url);
}
}
});
Also, if you have any further questions, please contact support#branch.io to give better assistance.

Related

How to use Google Translate TTS with the new V2 API?

I used to call Google Translate TTS to download an audio file using this url:
http://translate.google.com/translate_tts?tl=en&q=Hello+world!
However Google changed the way that works and therefore I can no longer download the audio files.
I've signed up for a free trial for Google Translate API V2, but can't find how to get the TTS audio files.
Any idea?
You can use that link without captcha..
https://translate.google.com/translate_tts?ie=UTF-8&tl=tr-TR&client=tw-ob&q=Batsın+bu+dünya+bitsin+bu+rüya
I stumbled across this thread and wanted to give my take on it, with reference to #Alexandre Andrade, mainly because he didn't submit any code.
I did this in a react app, but the same procedure should works for a vanilla web project.
I did add the meta tag to my head public/index.html,
<head>
...
<meta name="referrer" content="no-referrer">
...
</head>
Then added the audio tag in my component:
Javascript:
const playTTS = (text, lang) => {
// Get the audio element
const audioEl = document.getElementById('tts-audio');
const url= `https://translate.google.com/translate_tts?ie=UTF-8&tl=${lang}&client=tw-ob&q=${text}`;
// add the sound to the audio element
audioEl.src = url;
//For auto playing the sound
audioEl.play();
};
html
...
<audio controls id="tts-audio"/>
...
Then it's just a matter of hooking the function up to some of your life cycle methods. Since I wrote my react code in react hooks, I added the function call in one of my hooks to get it initialized when the component was loaded. (this would be in the componentDidMount() function otherwise).
Hope this helps anyone out!
try this link for English:
https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Hello+World
For Chinese (Puthonghua)
https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=zh-CN&q=世界+你好
Text-to-speech was always an 'unofficial' API which is now captcha-protected to prevent abuse. It was never advertised as part of the Translate API, and currently there is no TTS functionality in the Translate V2 API, paid or otherwise.
There is some more background on the following groups thread which had been ongoing for some time.
Here's to those who have desperately been trying to play Google TTS as an audio in HTML: let me save you a couple of hours of time and tell you how to do it.
Let's say we have this link:
https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=I+love+coffee
If you try to play this audio given the link and using <audio>, <iframe>, using third-party libraries or playing it with Javascript...
var audio = new Audio('https://translate.google.com/translate_tts...');
audio.play();
...then you'll soon find out that none of the aforementioned ways work as Error 404 is being thrown.
Solution
Apparently, the only possible way to play this TTS generic audio is to utilise <embed> tag wrapped into a custom <iframe> and giving the link a unique version number (it is important, as caching by browsers prevents the audio from playing for some reason).
Here is the solution for our example: (assuming you have an iframe#ttsiframe)
function playTTS(lang,sentence) {
//get the iframe
var iFrame = document.getElementById('ttsiframe');
//remove its sandbox property
iFrame.removeAttribute('sandbox');
//this is your reference variable for the iframe body and head tag
var iFrameBody;
//get the body
if (iFrame.contentDocument) { // FF
iFrameBody = iFrame.contentDocument.getElementsByTagName('body')[0];
iFrameHead = iFrame.contentDocument.getElementsByTagName('head')[0];
}
else if (iFrame.contentWindow) { // IE
iFrameBody = iFrame.contentWindow.document.getElementsByTagName('body')[0];
iFrameHead = iFrame.contentWindow.document.getElementsByTagName('head')[0];
}
else {
iFrameBody = iFrame.contentDocument.body;
iFrameHead = iFrame.contentDocument.head;
}
//generate link to Google Translate TTS using arguments (pay attention to random version number at the end)
var link = 'https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=' + lang + '&q=' + sentence.replace(/ /g,'+').replace(/[.]/g,'') + '&rd=' + getRandomInt(0,50000000);
//add embed element with our link
iFrameBody.innerHTML = '<embed src="' + link + '" id="TTS">';
//isolate iframe
iFrame.setAttribute('sandbox','');
}
you can simply use the link:
Text to Speech

API Twitter 1.1 account/update_profile_image

I do not know at all how to get the avatar of the profile of a twitter account: /
Even looking at the DOC here:
https://dev.twitter.com/rest/reference/post/account/update_profile_image
If a kind person could help me.
Here is my code without the class
if(isset($_GET['name']))
{
$name= htmlentities($_GET['name']);
}
$cache = 'cache/tweets.tmp';
if(time() - filemtime($cache) > 60){
require 'class/twitteroauth.php';
$connection = new TwitterOAuth('***','****', '**-**', '****');
$pics = $connection->post('account/update_profile_image','//screen_name => HERE...$name....');
//var_dump($pics);
file_put_contents($cache, serialize($pics));
}else{
echo 'Cache utilisé';
$pics = unserialize(file_get_contents($cache));
}
You're looking at the documentation for updating a Twitter user's profile image. From your question, I take it that you simply want to get this image. Remember a POST request is meant for creating new content, not simply GETting it.
Have a look at this:
https://dev.twitter.com/rest/reference/get/users/show
The users/show method provides various information about the user, including a link to the image with the key profile_image_url.
This answer should provide more detail to help you figure it out.

Attach photo to Activity through Google + Domains API

Im trying to post an activity with an image to a google+ domain with the new google + domains API
Posting an activity is working fine but when i try to attach a photo to it, i receive a 500 error with null description.
This is the code:
String msg = "Activity with photo";
// Create a list of ACL entries
PlusAclentryResource resource = new PlusAclentryResource();
resource.setType("domain"); // Share to domain
List<PlusAclentryResource> aclEntries = new ArrayList<PlusAclentryResource>();
aclEntries.add(resource);
Acl acl = new Acl();
acl.setItems(aclEntries);
acl.setDomainRestricted(true); // Required, this does the domain restriction
// Create a new activity object
Activity activity = new Activity()
.setObject(new Activity.PlusObject().setOriginalContent(msg))
.setAccess(acl);
// Attach the link
Activity.PlusObject.Attachments attachment = new Activity.PlusObject.Attachments();
attachment.setObjectType("photo");
attachment.setUrl( "http://c299813.r13.cf1.rackcdn.com/MuseeduLouvre_1335428699_org.jpg" );
attachment.setId( randomId ); //if not specified, google returns an error with "you must specify the photo id"
List<Activity.PlusObject.Attachments> attachments = new ArrayList();
attachments.add(attachment); // You can also add multiple attachments to the post
activity.getObject().setAttachments(attachments);
activity = plus.activities().insert("me", activity).execute();
When the code calls the execute, i receive this error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 500
{
"code": 500,
"message": null
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
The same code but with the attachemnt lines commented works fine. Has someone managed to create an activity with an image? any clue?
Thanks in advance.
Directly attaching a photo via URL isn't possible. The process works slightly differently, as described here: https://developers.google.com/+/domains/posts/attaching-media
If you don't have the actual binary data of the photo you will first have to "download" the photo. Then you can upload the actual photo data via the media().insert method, which will give you the Photo Id which you can then use in attachment.setId().
setUrl isn't necessary in this case.
If you want to attach a photo as URL, this could also be handled like an article attachment (same as if you would just copy/paste the URL into a Google+ post). In that case you would use attachment.setObjectType("article") and only set the Url. The id isn't necessary in this case.

View Switch doesn't work with 51Degrees

I have got a MVC4 application where I used 51Degrees (Lite) to detect device and accordingly select the mobile (.mobile.cshtml) or desktop (.cshtml) view. 51Degrees can properly do that job. However if I want to switch from Mobile to Desktop view (on a mobile device) using HttpContext.SetOverriddenBrowser(BrowserOverride.Desktop) it doesn't work. FYI, it works without 51Degrees.
Here is the code to select display mode (Application_Start() in Global.asax.cs):
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("mobile")
{ContextCondition = Context =>Context.Request.Browser["IsMobile"] == "True"
});
Here is the view switcher controller action code:
public class ViewSwitcherController : Controller
{
public RedirectResult SwitchView(bool mobile, string ReturnUrl="/Login/Login")
{
// If the mobile user has requested to view the mobile view
// remove any overridden user agent for the current request
if (Request.Browser.IsMobileDevice == mobile)
HttpContext.ClearOverriddenBrowser();
else
// Otherwise override the browser setting to desktop mode
HttpContext.SetOverriddenBrowser(mobile ? BrowserOverride.Mobile : BrowserOverride.Desktop);
return Redirect(ReturnUrl);
}
}
Here is the code in the view to switch to Desktop view:
#Html.ActionLink("Desktop view", "SwitchView", "ViewSwitcher", new { mobile = false, ReturnUrl = Request.Url.PathAndQuery }, new { rel = "external" })
Please let me know if I'm missing something.
Thanks in advance.
Sorry for my long delayed answer.
The following solution was provided by one of the developers at 51Degrees:
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("mobile")
{
ContextCondition = Context => Context.GetOverriddenBrowser()["IsMobile"] == "true"
});
So replacing Context.Request.Browser["IsMobile"] with Context.GetOverriddenBrowser()["IsMobile"] fixes my problem.
Hope that helps.
I know this is a bit dated, but I ran into this tonight. Same symptoms. Works without Mobi51, does not with. My working theory is that Request.Browser.IsMobileDevice is touched by Mobi51 and it takes control of that property and sets its value regardless of what you would expect .NET to do with it.
My current solution is this. When I check in my viewstart file to switch layouts I check that both Request.Browser.IsMobileDevice and Context.GetOverridenBrowser().IsMobileDevice are true.
When it's truly Mobile, both will be true. When it's truly desktop, both are false. When it's a mobile view requesting desktop, Request.Browser.IsMobileDevice will be true (because Mobi51 says so) and Context.GetOverridenBrowser().IsMobileDevice will be false. Here's my viewstart
#{
Layout = Request.Browser.IsMobileDevice && Context.GetOverriddenBrowser().IsMobileDevice
? "~/Views/Shared/_LayoutMobile.cshtml"
: "~/Views/Shared/_Layout.cshtml";
}
I'm still vetting this and have to add desktop to mobile switching still (which I can already see a problem, but the change to make that direction work as well is easy enough , but in my five minutes of testing so far tonight this has worked. I'm curious if you found another reason/way to work with this, or if this solution is satisfactory for you.

Captcha image and raw format

I've trying to get properly work kcaptcha class from kcaptcha.ru in my own component. 'Cause class not build for Joomla natively I break my brain on the wall.
And at the beginning...
I've a url to image generated by this class like: http://.../index.php&task=captcha&format=raw
In main controller I've put method
function captcha() {
include(JPATH_COMPONENT.DS.'libraries'.DS.'captcha'.DS.'kcaptcha'.DS.'kcaptcha.php');
$session = &JSession::getInstance('default', array());
$captcha = new KCAPTCHA();
if ($session) {
$session->set('captcha_keystring', $captcha->getKeyString());
}
}
And I've see in browser
When I request an image from the class all working good but in my component I cannot set session variables.
Any ideas how to fix this problem?
And problem solved successfully.
For &format=raw in controller Joomla set default mime-type to text/html.
For healing this issue developer must reset mime/type via setting
$document = &JFactory::getDocument();
$document->setMimeEncoding('image/png');
mime/encoding off course depends on you needs.