Including map in open graph post [Android] - facebook-android-sdk

This has really been confusing me. I have a object which inherits from 'Place' and I add geo location, yet when I post I see no map appear. If anyone could link to a tutorial or give me an answer it would be greatly appreciate. Here is my current code for my object, thanks
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "myapp:log")
.putString("og:title", "Title")
.putString("og:description", "Desc")
.putString("place:location:latitude","1.0")
.putString("place:location:longitude","1.0")
.build();

Related

Telegram quiz message handler but don't know how to display correct answer when answered

Here is a sample of the code that I am using would be gratefully if someone can point me in the right direction.
import telebot
bot = telebot.TeleBot("API KEY")
print("Bot starting...")
#bot.message_handler(commands=['quiz'])
def quiz(message):
q = 'What is the capital of Italy?'
answers = ['Rome', 'London', 'Amsterdam']
bot.send_poll(message.chat.id, question=q, options=answers, correct_option_id=0, open_period=5)
bot.polling()
What I'm not sure about on how to make work, is once the question has been answered how to display the correct answer out of the options that are available. For Example the question above, for it to say the correct answer is "Rome" after each question.
Thank You in advance
If you pass type='quiz' to send_poll, then TG will automatically take care of that. See the official docs of sendPoll.
If you don't want to the native quiz interface of TG, you'll have to make the poll non-anonymous. In that case, you'll receive PollAnswer updates when a user makes a vote and you can respond to that update in the way that you want to.

Symfony3 Doctrine2 Column cannot be null

[PROBLEM SOLVED]
Hey folks I need your help on a symfony project.
I have two entities, "article" and "image", article can have several images so I made a relationship OneToMany on the article side and ManyToOne on the image side. Doctrine generates for me an "article_id" column on the image table.
I made a form to create an article with one or more images... however when I execute it I have an error that is thrown :
An exception occurred while executing 'INSERT INTO image (url, alt, article_id) VALUES (?,?,?) 'with params ["jpeg", "untitled.jpg", null]: SQLSTATE [23000]: Integrity constraint violation: 1048 Column' article_id 'can not be null.
When I look to the profiler logs debug, I can see that I have an "INSERT INTO article[...]" (so the article is created with an ID ?) and just after this I have the famous "INSERT INTO image[...]" where the error occurs.
Thank you for your help.
EDIT In bold you will find the lines I added to solve this problem.
I added into the ArticleType form, in the images collection options this :
'by_reference' => false
And I added to the addImage method into the Article entity this :
$image->setArticle($this);
$this->images->add($image);
This is a very common question but surprisingly difficult to search for. In fact the first ten or so search results had incorrect answers.
In any event, you need to make sure that image is linked to the article.
class Article
public function addImage($image) {
$this->images[] = $image;
$image->setArticle($this); // ADD THIS
I think #Cerad's answer is very wrong, although I can't blame him because OP hasn't posted enough code, don't be shy with it, we're here to help. It also helps to briefly mention if you're just starting out (as I suspect you are) as it will help us gauge whether its a novice problem or something deeper.
Since I'm assuming it's a novice problem here is the novice solution.
With they way you've mapped (which I believe is correct) you are basically telling Doctrine to Tell your RDBMS (MySql/MariaDB/PostgreSQL) that an article CAN have many images, but an image MUST belong to an article.
This means that if you attempt to save an image without specifying the owning article, it will throw an error.
This is what I think you are doing evident in the line
(url, alt, article_id) VALUES (?,?,?) 'with params ["jpeg", "untitled.jpg", null]
the value "null" is where the issue is coming about because you are not specifying the owning article.
You have 2 options
1.) When saving image, if you have the article object at hand just do
$image->setArticle($article);
2.) When saving the image, if you have the article_id at hand just do
$image->setArticle($em->getReference('AppBundle\Entity\Articles', $article_id));
You must follow one of the above when saving an image directly.
My general experience has been that Doctrine does a really good job of generating entities from command line that you really don't need to change much unless adding some advanced functionality like second_level_cache or MySQL point type.
Cheers.
The problem is that when you submit your form, the first image is attached to the article but the others are not, so you get an SQL error.
You have to do a "foreach loop" for every image and attched the article to each one.
Look here at the addAction function
https://github.com/ismail1432/TheGoodLoc/blob/master/Symfony/src/VTC/AnnonceBundle/Controller/AdvertController.php

Automatically add a voucher code if the URL conains a KeyWord in Prestashop

The main goal that I want to achieve is to add a voucher code if the user has clicked on a specific external link that point to my shop.
So the (javascript?) script will analyze the url and if it contains any selected keyword will add the voucher.
Anyone knows how to do that?
Thanks
I found a pretty simple solution.
I made a module.
You can find it here: GITHUB
Was pretty easy:
Generated a basic module HERE
Selected Header Hook for my new module
Modified the header hook function in the modulename.php file in root with this one:
public function hookHeader()
{
$this->context->controller->addJS($this->_path.'/views/js/front.js');
$this->context->controller->addCSS($this->_path.'/views/css/front.css');
if (Tools::getValue('voucher')){
$cartVoucher = Tools::getValue('voucher');
$idDiscount = Discount::getIdByName($cartVoucher);
Context::getContext()->cart->addDiscount($idDiscount);
}
}
Hope will help someone.
Thanks to all.

TextControl Images/Watermarks

In version 18 of TextControl (http://www.textcontrol.com) there is supposed to be the ability to add background images/watermarks to the document, however I find that the behavior of the various overloads, etc is not working correctly and that the documentation is rather scarce on examples. Does any one have a working example of adding watermarks to a Word document through the ServerTextControl object?
This functionality didn't exist in previous versions, so I recognize it's still rather new, I just find it weird that doing something like
tx.Images.Add(draftImage, pageNumber, location, ImageInsertionMode.BelowTheText);
doesn't actually add the images to the document, but if I use another overload beforehand, it adds both?
I just need a loop along the lines of
foreach (TXTextControl.Page page in pages){
page.Select();
var location = tx.InputPosition.Location;
var pageNumber = page.Number;
tx.Images.Add(draftImage, pageNumber, location, ImageInsertionMode.BelowTheText);
}
where location is supposed to be the beginning of the page.
Any help would be appreciated, this should be simple!
Thank you
Finally got a response to this on their forum, it's not a complete solution, but it works for the most part. Figured I would follow up here, so that anyone who ends up on this page would get the help I wanted.
http://forums.textcontrol.com/showthread.php?325522-Watermarking-Background-Image-on-Saved-Documents-in-X8&p=41815#post41815

Get Page URL using Sitefinity 4 Fluent API

Okay, this seems like a pretty simple thing to do. But I'm trying to use the Sitefinity 4 Fluent API to query for a page and populate the Text/NavigationUrl properties of a HyperLink. The text gets populated fine - but it has a hard time getting the Url from the page.
PageNode page = App.WorkWith().Page(PageId).Get();
PageLink.Text = page.Title;
PageLink.NavigateUrl = page.Urls.Where<PageUrlData>(pU => pU.RedirectToDefault == false).FirstOrDefault<PageUrlData>().Url;
The first and second line work fine (PageLink.Text shows the page title). On the third line, I get an "Object reference not set to an instance of an object." error... FYI PageId is a Guid reference to a page.
Any help would be greatly appreciated.
Found the issue. PageNode requires "Telerik.Sitefinity.Pages.Model" as a reference. I had that, but later found that you ALSO need to include "Telerik.Sitefinity.Modules.Pages".
This adds a new method to my belt which I've used below (getFullUrl):
PageNode page = App.WorkWith().Page(PageId).Get();
PageLink.Text = page.Title;
PageLink.NavigateUrl = page.GetFullUrl();
Thanks