facebook share Fb.ui description line break [duplicate] - php

This is an URL I have to send an invitation to an app of mine:
https://www.facebook.com/dialog/send?app_id=MY_APP_ID&
name=hola&
link=http://www.aWebSite.com&
picture=http://www.aWebSite.com/im01068442.jpg&description=participar!&
redirect_uri=http://elsuperdt.com
I'm trying to have a linebreak included within the description, but I just haven't found a way to do so. How do I do it?

I had the same issue and eventually gave up. Facebook seems to have gone to great lengths to avoid letting us have any linebreaks in the description.
The one thing you can do is add a &caption=first%20line which gets you one linebreak between the caption and the description. (There's a pretty short limit on how long the caption can be though - something like 80 characters.)
Update: this no longer works for send dialogs. It does still work for feed dialogs

Try using <center></center> this will create a new line in Facebook dialog description.

Try including %0D%0A in your description where you want the line break to be. This is the URL-encoded equivalent of a line break.

\n works in message but not in name parameter

I tried center></center> and %0D%0A. Both worked... for a split second. You could see the breaks upon page load, and then, like evil magic, facebook took it away and it was all scrunched up. Too bad. I'm trying to share a daily schedule, which would look much better with line breaks.

You can use blanks that are not posted to facebook in the length of the feed so the line breaks.
Or you just style your post by adding ".........." in the end of each line. This way people would maybe be more attracted to your post as they are eyecatching.

Related

PDFLIB: line breaking is not working, can't find the proper options to set it

I am using pdflib 9.0.1 on php to generate some text pdfs.
I am stuck on line breaking at the end of the line. I need to place a text on several columns and with alignment=justify, so the word has to be splitted in 2 parts and the first remains on current line, a dash is set at the end, and the rest goes to the next line. Seems easy, to explain, but I am not getting any result on pdflib.
I've tried creating the textflow with some options like locale=de_DE, advancedlinebreak=true, adjustmethod and also using script option, but without success.
The options I found, for controlling the line break algorithm are here on the PDFlib-9.0.1-API-reference on page 92.
If some "good samaritan" has some clue, it would be welcome!
Thanks in advance!
you need to add the option "avoidbreak=true"

Magento Order comment update - Notify customer email formatting issue

This is my first post on the forums, i've been lurking forever now. About time to say hello! I did use the search, but either nobody else has this specific issue, or they don't utilize the comment section the way we do.
We like to send updates to customers through the order comment section of the order page. The email that is sent does not hold any of the line breaks that were used in the original comment. If you have 5 separate sentences, the email shows one big paragraph.
This is really annoying, because our message becomes a big mess. We have to give the customer a series of information about their order, and instructions on how to process with the issue on hand.
Here's two images of what i'm talking about
I have images but I can't post them because I need 10 rep. hmm..
As you can see, this is just an example and not a long comment, But our regular emails can have a lot of information, and maybe some up-selling.
I haven't tested it myself, but David Manners' answer on this question on the Magento Stack Exchange sounds promising.
Basically he suggests running the comments through nl2br to convert the newlines to tags that would render in HTML email, like this:
{{var data.comment:escape|nl2br}}

Adding a line break in Facebook's og:description using a php lanuage file [duplicate]

This is an URL I have to send an invitation to an app of mine:
https://www.facebook.com/dialog/send?app_id=MY_APP_ID&
name=hola&
link=http://www.aWebSite.com&
picture=http://www.aWebSite.com/im01068442.jpg&description=participar!&
redirect_uri=http://elsuperdt.com
I'm trying to have a linebreak included within the description, but I just haven't found a way to do so. How do I do it?
I had the same issue and eventually gave up. Facebook seems to have gone to great lengths to avoid letting us have any linebreaks in the description.
The one thing you can do is add a &caption=first%20line which gets you one linebreak between the caption and the description. (There's a pretty short limit on how long the caption can be though - something like 80 characters.)
Update: this no longer works for send dialogs. It does still work for feed dialogs
Try using <center></center> this will create a new line in Facebook dialog description.
Try including %0D%0A in your description where you want the line break to be. This is the URL-encoded equivalent of a line break.
\n works in message but not in name parameter
I tried center></center> and %0D%0A. Both worked... for a split second. You could see the breaks upon page load, and then, like evil magic, facebook took it away and it was all scrunched up. Too bad. I'm trying to share a daily schedule, which would look much better with line breaks.
You can use blanks that are not posted to facebook in the length of the feed so the line breaks.
Or you just style your post by adding ".........." in the end of each line. This way people would maybe be more attracted to your post as they are eyecatching.

Running preg_replace on html code taking too long

At the risk of getting redirected to this answer (yes, I read it and spent the last 5 minutes laughing out loud at it), allow me to explain this issue, which is just one in a list of many.
My employer asked me to review a site written in PHP, using Smarty for templates and MySQL as the DBMS. It's currently running very slowly, taking up to 2 minutes (with a entirely white screen through it all, no less) to load completely.
Profiling the code with xdebug, I found a single preg_replace call that takes around 30 seconds to complete, which currently goes through all the HTML code and replaces each URL found to its SEO-friendly version. The moment it completes, it outputs all of the code to the browser. (As I said before, that's not the only issue -the code is rather old, and it shows-, but I'll focus on it for this question.)
Digging further into the code, I found that it currently looks through 1702 patterns with each appropriate match (both matches and replacements in equally-sized arrays), which would certainly account for the time it takes.
Code goes like this:
//This is just a call to a MySQL query which gets the relevant SEO-friendly URLs:
$seourls_data = $oSeoShared->getSeourls();
$url_masks = array();
$seourls = array();
foreach ($seourls_data as $seourl_data)
{
if ($seourl_data["url"])
{
$url_masks[] = "/([\"'\>\s]{1})".$site.str_replace("/", "\/", $seourl_data["url"])."([\#|\"'\s]{1})/";
$seourls[] = "$1".MAINSITE_URL.$seourl_data["seourl"]."$2";
}
}
//After filling both $url_masks and $seourls arrays, then the HTML is parsed:
$html_seo = preg_replace($url_masks, $seourls, $html);
//After it completes, $html_seo is simply echo'ed to the browser.
Now, I know the obvious answer to the problem is: don't parse HTML with a regexp. But then, how to solve this particular issue? My first attempt would probably be:
Load the (hopefully, well-formed) HTML into a DOMDocument, and then get each href attribute in each a tag, like so.
Go through each node, replacing the URL found for its appropriate match (which would probably mean using the previous regexps anyway, but on a much-reduced-size string)
???
Profit?
but I think it's most likely not the right way to solve the issue.
Any ideas or suggestions?
Thanks.
As your goal is to be SEO-friendly, using canonical tag in the target pages would tell the search engines to use your SEO-friendly urls, so you don't need to replace them in your code...
Oops ,That's really tough, bad strategy from the beginning , any way that's not your fault,
i have 2 suggestion:-
1-create a caching technique by smarty so , first HTML still generated in 2 min >
second HTMl just get from a static resource .
2- Don't Do what have to be done earlier later , so fix the system ,create a database migration that store the SEO url in a good format or generate it using titles or what ever, on my system i generate SEO links in this format ..
www.whatever.com/jobs/722/drupal-php-developer
where i use 722 as Id by parsing the url to get the right page content and (drupal-php-developer) is the title of the post or what ever
3 - ( which is not a suggestion) tell your client that project is not well engineered (if you truly believe so ) and need a re structure to boost performance .
run

How to detect nonsensical text in PHP?

I have comments enabled on my site and I require users to enter at least 30 characters to publish their comments (Just to get some value because they usualy just submitted "I like it")
But some users now use simple technique to overcome this and enter e.g.:
"I like it. asdsdf dfdsfsdf tt erretrt re"
As you can see the rest of the text is nonsense. Is there a way (algorithm) how to filter these comments out in PHP ?
Get a dictionary of English words from the net. Check the post has a certain % (maybe 50%? maybe 70%?) of words that are in the dictionary. You can't look for 100%, or names and technical jargon will not be found.
users will get around this by entering.
I like it ....................................................
So then add logic to parse out punctuation.
Then users will get around it with
I like it. the the the the the the the the
Then you will need to parse it for proper English grammer
Then no one will be able to post on your site becuase it has too many rules.
Better suggestion: Add comment moderation. Dumb posts get downvoted and go away. Good posts stay.
Check out the Akismet PHP5 class.
$WordPressAPIKey = 'KEYHERE';
$MyBlogURL = 'http://www.example.com/blog/';
$akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
$akismet->setCommentAuthor($name);
$akismet->setCommentAuthorEmail($email);
$akismet->setCommentAuthorURL($url);
$akismet->setCommentContent($comment);
$akismet->setPermalink('http://www.example.com/blog/alex/someurl/');
if($akismet->isCommentSpam()) {}
You can use a naive bayesian filter for this. http://www.paulgraham.com/better.html
There are probably existing libraries for this kind of thing. Check out spam assassin.
I'd do a simple check on consecutive consonants or vowels. If there are more than four of any in a row, than there is a high probability of nonsense. Furthermore, check for more than two repetitions of the same character. When looking at some nonsense text, I'm sure you'll find some pragmatic reciepes ;-)
Personally, I would say there's not much you can do about it. Even if you had a dictionary and parser, what if I were to leave a comment: "I like it. As do I like your car." Depending on what they're leaving a comment for, that could be complete nonsense. Best I can say is have an edit available for each comment so that you or a mod or whomever can edit it. Sorry that this isn't of any help.
I had this same issue when trying to create password restrictions. Words couldn't be used, so we needed to use a dictionary, but there is never a comprehensive dictionary. And the biggest thing was eliminating l33t speak. :)
Unfortunately not, your best bet is to modify something like this: Get Spelling Corrections From Google. When messages are close to the 80 character limit, you could look up each word individually and if it doesn't have a direct hit, boot out the input.

Categories