Create a Facebook App using codeigniter - codeigniter

I want to create a Facebook App using codeiginiter but I've got always the same error :
In french : L’URL fournie n’est pas autorisée par la configuration de l’application.: Une ou plusieurs URL fournies ne sont pas autorisées par les paramètres de l’application. Elle(s) doi(ven)t correspondre à l’URL du site ou du Canevas, ou le domaine doit être un sous-domaine de l’un des domaines de l’application.
Google translate in english : The URL provided is not permitted by the application configuration. One or more URLs provided are not permitted by the settings of the application. She must match the URL of the site or Canvas, or the field must be a subdomain of one of the fields of application.
Here my code :
class Welcome extends CI_Controller {
public function index()
{
parse_str( $_SERVER['QUERY_STRING'], $_REQUEST );
$CI = & get_instance();
$CI->config->load("facebook",TRUE);
$config = $CI->config->item('facebook');
$this->load->library('Facebook', $config);
// Try to get the user's id on Facebook
$userId = $this->facebook->getUser();
// If user is not yet authenticated, the id will be zero
if($userId == 0){
// Generate a login url
$data['url'] = $this->facebook->getLoginUrl(array('scope'=>'email', 'redirect_uri' => 'https://apps.facebook.com/dressthingstests/'));
$this->load->view('app/index', $data);
} else {
// Get user's data and print it
$user = $this->facebook->api('/me');
print_r($user);
}
}
}
The url var is not empty : https://www.facebook.com/dialog/oauth?client_id=XXXXXXXXXX&redirect_uri=https%3A%2F%2Fapps.facebook.com%2Fxxxxxxtests%2F&state=xxxxxxxxxxxxxxxxxxxxxxxx&scope=email
Any idea ? :/
Thanks a lot.

Related

update image in laravel 8 - API

I tried update my image, but it isn´t update.
I have the method upload , it works in a store method
private function upload($image)
{
$path_info = pathinfo($image->getClientOriginalName());`
$post_path = 'images/post';
$rename = uniqid() . '.' . $path_info['extension'];
$image->move(public_path() . "/$post_path", $rename);
return "$post_path/$rename";
}
I tried update the new image, but the message update successfully apears but not update
public function update(Request $request, Car $car)
{
if (!empty($request->file('image_url'))) {
$url_image = $this->upload($request->file('image_url'));
$car->image_url = $url_image;
}
$res = $car->save();
if ($res) {
return response()->json(['message' => 'Car update succesfully']);
}
return response()->json(['message' => 'Error to update car'], 500);
}
La actualización es correcta pero en la BDD no actualiza
Imagen de actualización con POSTMAN
Try changing the method in postman to POST and add this query string parameter to the URL: its name is _method and the value is PUT.
Your API consumers will call the endpoint in this way but you will keep the route definition with the PUT verb. Read more about it here
The request PUT doesnt have a body like the method POST as of the RFCs (Something with the Content-Length, dont remember correctly).
Even if your API can handle PUT methods with body, your postman will try to send the file in the query field (URL) and that will mostly break the file. You can check the URL called by postman in the request Headers.
Laravel has a workaround for this, you send the parameter _method=PUT in a POST request and the router will handle it as a PUT request (if you declared it so).

How to send password reset link in auto generated email template in magento

As shown in the screenshot, in the customer information when the password is set from admin and then changes are saved, an email is send to the customer. By default, the new password and account link is send in the email.
What I want to ask is that, is it possible to send the link of password reset also in this email?
I think the template used is:
app/locale/en_US/template/email/password_new.html
I tried to add following:
{{store url="customer/account/resetpassword/" _query_id=$customer.id _query_token=$customer.rp_token}}
But I am getting error on frontend as:
Your password reset link has expired.
Yes you can -- You can generate new reset password token & set it to customerObject - Try something like
/** #var $customer Mage_Customer_Model_Customer */
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail("customer#gmail.com"); //change the email
if ($customer->getId()) {
try {
$newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
$customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
$customer->sendPasswordResetConfirmationEmail();
} catch (Exception $exception) {
Mage::log($exception);
}
}
So looks like the reset token is not generate for that email generated from the administrator.
I was able to fix this in 1.9.1.0 by creating a controller override for the app/code/core/Adminhtml/controllers/CustomerController.php files (per these instructions http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/ -- Adminhtml controller override section).
Copy the saveAction method to the override.
Inside the saveAction method, look for this block of code around line 351 (original file).
if (!empty($data['account']['new_password'])) {
$newPassword = $data['account']['new_password'];
if ($newPassword == 'auto') {
$newPassword = $customer->generatePassword();
}
$customer->changePassword($newPassword);
$customer->sendPasswordReminderEmail();
}
Change this block to
if (!empty($data['account']['new_password'])) {
$newPassword = $data['account']['new_password'];
if ($newPassword == 'auto') {
// no token generated
//~ $newPassword = $customer->generatePassword();
$newResetPasswordLinkToken = Mage::helper('admin')->generateResetPasswordLinkToken();
$customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
}
$customer->changePassword($newPassword);
$customer->sendPasswordReminderEmail();
}
To have the token generated and added to the password reset email from the admin.

magento pass variable from controller to another model

I want to send custom mail through smtp.For which I installed http://www.magentocommerce.com/magento-connect/aschroder-com-smtp-pro-email-free-and-easy-magento-emailing-for-smtp-gmail-or-google-apps-email.html.
Which works properly for every mail provided by magento as default.
Now since the admin is having mail Id of google apps , my custom mail is not received by admin.So for this reason I want to Integrate my controller with the sending mail function of ashrodder extension.
My Controller code:
$frm = 'mail#domainname.com';
$to = 'admin#domainname.com';
$subject = "UPDATE";
$mail = new Zend_Mail('utf-8');
$mail->setBodyHtml($message)
->setFrom($frm, 'Admin')
->addTo($to, 'Site Admin')
->setSubject($subject);
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Mail sent successfully.');
}
catch(Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send email.');
}
My question is simple : How should I pass [to,from,body] variable to any other model/controller ?
Please Help .Thanks in Advance
I think overriding the extensions controller would be the best solution.Check this link How to extend a controller

Magento - show a custom customer attribute in new oder validation E-mail

How can I show the value of a custom customer attribute in new oder validation E-mail, using Magento ver. 1.4.1.1
I have added this code to /sales/model/order.php :
public function getCustomerNumber() {
if (!$this->getCustomerId()) return;
$customer = Mage::getModel('customer/customer')->load( $this->getCustomerId());
$customer = $customer->getData('customer_number');
return ($customer);
and {{var order.getCustomer()}} in order email template but it get the word 'Object' and not the right value.
Thanks for help.

Adding unsubscribe link in custom email magento

How to add unsubscribe link in custom email notification i am sending an email through zend mail function i follow this function sending mail in magento in body part i want to add unsubscribe link how can we implement that?
In my e mail notification i am using this function.
public function sendMail()
{
$post = $this->getRequest()->getPost();
if ($post){
$random=rand(1234,2343);
$to_email = $this->getRequest()->getParam("email");
$to_name = 'Hello User';
$subject = ' Test Mail- CS';
$Body="Test Mail Code : ";
$sender_email = "sender#sender.com";
$sender_name = "sender name";
$mail = new Zend_Mail(); //class for mail
$mail->setBodyHtml($Body); //for sending message containing html code
$mail->setFrom($sender_email, $sender_name);
$mail->addTo($to_email, $to_name);
//$mail->addCc($cc, $ccname); //can set cc
//$mail->addBCc($bcc, $bccname); //can set bcc
$mail->setSubject($subject);
$msg ='';
try {
if($mail->send())
{
$msg = true;
}
}
catch(Exception $ex) {
$msg = false;
//die("Error sending mail to $to,$error_msg");
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($msg));
}
}
If you have a custom module use this code:
Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getUnsubscriptionLink();
Explanation:
first part is the model for the subscriber.
If you want to see al the available methods within the model just use this code:
$myModel = Mage::getModel('newsletter/subscriber');
foreach (get_class_methods(get_class($myModel)) as $cMethod) {
echo '<li>' . $cMethod . '</li>';
}
the second part of the code loadByEmail($email) is to get 1 specific subscriber object. $email should be a string of the emailaddress.
The last part of the code is a selfexplaning method. It will generate a link to unsubscribe. This is a method that is given by Magento.
In my Magento version I get the following code by default when creating a new newsletter template:
Follow this link to unsubscribe <!-- This tag is for unsubscribe link -->{{var subscriber.getUnsubscriptionLink()}}
I expect it to work in any Magento version.
I am using Magento 1.9.
To add newsletter unsubscribe link in newsletter template here are following steps:
Override the core file
/app/code/core/Mage/Newsletter/Model/Subscriber.php
by copy in local directory
/app/code/local/Mage/Newsletter/Model/Subscriber.php
Open in editor to edit the code and seacrh the function sendConfirmationSuccessEmail()
replace the code
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
$this->getEmail(),
$this->getName(),
array('subscriber'=>$this)
);
with this
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
$this->getEmail(),
$this->getName(),
array('subscriber'=>$this, 'unsubscribe' =>$this->getUnsubscriptionLink())
);
and place this code in email template where you want to use unsubscribe link:
Unsubscribe here
That's it!
Hope this helps someone.

Resources