I am working on a MemberMouse subscription Wordpress website. I want to get data of the user into the php file via API to a Mailchimp mailing list.
I wrote the following script, that should be called under the condition that once the script is loaded it sends the following php sript:
<?php
require_once 'MCAPI.class.php';
$apikey='Your-API-Key'; // Enter your API key
$api = new MCAPI($apikey);
$retval = $api->lists();
$listid='List-Id'; // Enter list Id here
$uname = $_GET["username"]; // Enter subscriber last name
$email = $_GET["email"]; // Enter subscriber email address
$merge_vars = array('FNAME' => $uname);
if($api->listSubscribe($listid, $email,$merge_vars) === true) {
echo 'success';
}
?>
However, it always gives me an error and can not read the user data.
Here is the Membermouse Wordpress Hooks: http://support.membermouse.com/support/solutions/articles/9000020294-membermouse-wordpress-hooks#member-data
And here if using PHP interface: https://membermouse.uservoice.com/knowledgebase/articles/319071-using-the-php-interface
The MCAPI.class.php is another php that reads data for Mailchimp. It is simply the MailChimp API PHP Class, which I integrated it into my project.
By the way, manually adding the member via the script above is no problem:
<?php
require_once 'MCAPI.class.php';
$apikey='Your-API-Key'; // Enter your API key
$api = new MCAPI($apikey);
$retval = $api->lists();
$listid='List-Id'; // Enter list Id here
$email='Subscriber-email-address'; // Enter subscriber email address
$name='Subscriber-first-name'; // Enter subscriber first name
// By default this sends a confirmation email - you will not see new members
// until the link contained in it is clicked!
$merge_vars = array('FNAME' => $name);
if($api->listSubscribe($listid, $email,$merge_vars) === true) {
echo 'success';
}
?>
Related
For the last five months, my Instagram account won't open. My other accounts have been working fine. Whenever I try to refresh my Instagram account, it just doesn't refresh. When I try to login on a browser, it takes me to a blank page and says "Oops an error occurred".
It's an authentication problem, account need to validate but you can't give verification code in SMS or email,
request verification code in SMS or email
<?php
set_time_limit(0);
date_default_timezone_set('UTC');
require __DIR__.'/../vendor/autoload.php';
use InstagramAPI\Exception\ChallengeRequiredException;
use InstagramAPI\Instagram;
use InstagramAPI\Response\LoginResponse;
//Enter these options
$username = 'username'; // your username
$password = 'password'; //your password
$verification_method = 1; //0 = SMS, 1 = Email
//Leave these
$user_id = '';
$challenge_id = '';
class ExtendedInstagram extends Instagram {
public function changeUser( $username, $password ) {
$this->_setUser( $username, $password );
}
}
$instagram = new ExtendedInstagram();
$loginResponse = $instagram->login( $username, $password );
$user_id = $instagram->account_id;
if ( $loginResponse !== null && $loginResponse->isTwoFactorRequired() ) {
echo '2FA not supported in this example';
exit;
}
if ( $loginResponse instanceof LoginResponse || $loginResponse === null ) {
echo "Not a challenge required exception...\n";
}
echo 'Logged in!';
?>
Instagram's private API Library
[SOLVED]
i was facing the same problem as " oops a error occurred" when i logged in to my Instagram account i tried resting the password, uninstalling and reinstalling the app but i faced the same problem i was searching to have a contact with the support team , i emailed to "Hi,
Thanks for contacting us. Before we can help, we need you to confirm that you own this account.
Please reply to this email and attach a photo of yourself holding a hand-written copy of the code below.
(secret code)
Please make sure that the photo you send:
- Includes the above code hand-written on a clean sheet of paper, followed by your full name and username
- Includes both your hand that's holding the sheet of paper and your entire face
- Is well-lit, and is not too small, dark or blurry
- Is attached to your reply as a JPEG file
Keep in mind that even if this account doesn't include any pictures of you or is used to represent someone or something else, we won't be able to help until we receive a photo that meets these requirements.
Thanks,
The Instagram Team
I sent them the required information and it resolved my problem within 8-12 hours.. i got y account back yupieee :D
Our sales team didn't receive the order confirmation email for 5 different orders. The cause of this problem is still unknown but they are asking if we can send the order confirmation emails to them again, without sending it to the client.
The "Send email" button on the order detail page is correctly sending the mail but there is no way to prevent the client to receive it.
Is there some way we could send this email to the sales team only, whether it's via the back office or, if not possible, programmatically ?
Thank you for you answers
We finally decided to make a script to send the emails programatically.
The script has been created in the following location:
/shell/resendEmails.php
You will only need to change the top-part parameters. The emails will be sent to this address instead of the customer's one. The Sales team will receive the copy has usual.
The code itself is mostly a copy of the function Mage_Sales_Model_Order::sendNewOrderEmail() with a few modifications
To execute the scrippt you need to access the page:
http://YOUR-SITE-URL.com/shell/resendEmails.php
(or whatever your script name is).
<?php
require '../app/Mage.php';
Mage::app();
/********************************
* Please modify the following parameters
********************************/
//The orders for you wich you want to send again the confirmation email
$order_numbers=array(
'xxxxxxx',
'yyyyyyy',
);
//Your email address (the email will be send to this address instead of to the customer's)
$custom_email="YOUR.EMAIL#ADDRESS.com";
$custom_name="YOUR NAME";
/**********************************
* Please modify the above parameters
**********************************/
foreach ($order_numbers as $increment_id){
$this_order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);
$storeId = $this_order->getStore()->getId();
// Get the destination email addresses to send copies to
$method = new ReflectionMethod(get_class($this_order), '_getEmails');
$method->setAccessible(true);
$send_to=$method->invoke($this_order,$this_order::XML_PATH_EMAIL_COPY_TO);
$copyTo=$send_to;
$copyMethod = Mage::getStoreConfig($this_order::XML_PATH_EMAIL_COPY_METHOD, $storeId);
// Start store emulation process
$appEmulation = Mage::getSingleton('core/app_emulation');
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
try {
// Retrieve specified view block from appropriate design package (depends on emulated store)
$paymentBlock = Mage::helper('payment')->getInfoBlock($this_order->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
} catch (Exception $exception) {
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
throw $exception;
}
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
// Retrieve corresponding email template id and customer name
if ($this_order->getCustomerIsGuest()) {
$templateId = Mage::getStoreConfig($this_order::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
$customerName = $this_order->getBillingAddress()->getName();
} else {
$templateId = Mage::getStoreConfig($this_order::XML_PATH_EMAIL_TEMPLATE, $storeId);
$customerName = $this_order->getCustomerName();
}
$mailer = Mage::getModel('core/email_template_mailer');
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($custom_email, $custom_name);
if ($copyTo && $copyMethod == 'bcc') {
// Add bcc to customer email
foreach ($copyTo as $email) {
$emailInfo->addBcc($email);
}
}
$mailer->addEmailInfo($emailInfo);
// Email copies are sent as separated emails if their copy method is 'copy'
if ($copyTo && $copyMethod == 'copy') {
foreach ($copyTo as $email) {
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($email);
$mailer->addEmailInfo($emailInfo);
}
}
// Set all required params and send emails
$mailer->setSender(Mage::getStoreConfig($this_order::XML_PATH_EMAIL_IDENTITY, $storeId));
$mailer->setStoreId($storeId);
$mailer->setTemplateId($templateId);
$mailer->setTemplateParams(array(
'order' => $this_order,
'billing' => $this_order->getBillingAddress(),
'payment_html' => $paymentBlockHtml
)
);
$mailer->send();
}?>
I've posted this question twice in the last two days and I have really run dry of solutions. I'm creating a very simple comment box that when filled out sends the comment in an email to my company's safety department. I have been receiving this 5.5.4 Invalid Domain Error for the last couple days.
It's SMTP and TLS. The port and server name is correct. The server allows for anonymous emails, and does not validate. I'm using the Swiftmailer library so I shouldn't need to script a ELHO/HELO. The only property of the email that's not defined/hard coded is the body of the message. This is the code for my controller (index.php).
// Initialize Swiftmailer Library
require_once("./swiftmailer/lib/swift_required.php");
// Class that contains the information of the email that will be sent (from, to, etc.)
require_once("./classes/EmailParts.php");
// The class that "breaks" the data sent with the HTML form to a more "usable" format.
require_once("./classes/ContactForm.php");
// =====================
// Main Configuration
// =====================
define("EMAIL_SUBJECT", "Safety Concerns");
define("EMAIL_TO", "safetydepartment#company.com");
define("EMAIL_FROM", "safetydepartment#company.com");
// SMTP Configuration
define("SMTP_SERVER", 'exchange.company.local');
define("SMTP_PORT", 25);
function main($contactForm) {
// Checks if something was sent to the contact form, if not, do nothing
if (!$contactForm->isDataSent()) {
return;
}
// Validates the contact form and checks for errors
$contactForm->validate();
$errors = array();
// If the contact form is not valid:
if (!$contactForm->isValid()) {
// gets the error in the array $errors
$errors = $contactForm->getErrors();
} else {
// If the contact form is valid:
try {
// send the email created with the contact form
$result = sendEmail($contactForm);
// after the email is sent, redirect and "die".
// We redirect to prevent refreshing the page which would resend the form
header("Location: ./success.php");
die();
} catch (Exception $e) {
// an error occured while sending the email.
// Log the error and add an error message to display to the user.
error_log('An error happened while sending email contact form: ' . $e->getMessage());
$errors['oops'] = 'Ooops! an error occured while sending your email! Please try again later!';
}
}
return $errors;
}
// Sends the email based on the information contained in the contact form
function sendEmail($contactForm) {
// Email part will create the email information needed to send an email based on
// what was inserted inside the contact form
$emailParts = new EmailParts($contactForm);
// This is the part where we initialize Swiftmailer with
// all the info initialized by the EmailParts class
$emailMessage = Swift_Message::newInstance()
->setSubject($emailParts->getSubject())
->setFrom($emailParts->getFrom())
->setTo($emailParts->getTo())
->setBody($emailParts->getBodyMessage());
// Another Swiftmailer configuration..
$transport = Swift_SmtpTransport::newInstance(SMTP_SERVER, SMTP_PORT, 'tls');
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($emailMessage);
return $result;
}
// Initialize the ContactForm with the information of the form and the possible uploaded file.
$contactForm = new ContactForm($_POST, $_FILES);
// Call the "main" method. It will return a list of errors.
$errors = main($contactForm);
// Call the "contactForm" view to display the HTML contact form.
require_once("./views/contactForm.php");
I've posted the entirety of my code at Dropbox. There's not much, but I think the problem must lie in the Index.
I have been searching the web for a few days now, but can't find anything that i can understand. I am looking for a way to login to OpenERP from a website i created. I want to fill the fields with the user data, and then redirect to OpenERP and login with that data.
Basically, i want to login to OpenERP from another webpage. I know this needs to be done with XML-RPC calls. But i don't know how to do it.
I need someone to explain this to me. How do i program the login using Xml-rpc?
I have checked the link: https://doc.openerp.com/v6.0/developer/6_22_XML-RPC_web_services/index.html/
But this didn't help me.
Thanks
basically, send an XML-RPC message containing parameters like the username and password to OpenERP's 'common' web service address.
Here is the sample login function from PHP xmlrpc i used to use:
<?php
include("xmlrpc.inc");
function login(){
$user = "admin";
$password = "1234";
$dbname = "devel";
$server_url= "http://127.0.0.1:8069/xmlrpc/";
$conn = new xmlrpc_client($server_url . 'common');
$msg = new xmlrpcmsg('login');
$msg->addParam( new xmlrpcval($dbname, "string") );
$msg->addParam( new xmlrpcval($user, "string") );
$msg->addParam( new xmlrpcval($password, "string") );
$resp = $conn->send( $msg );
$val = $resp->value();
$this->id = $val->scalarval();
return $this->id>0 ? $this->id : -1 ;
}
It will return -1 if login failed, otherwise the user ID from OpenERP.
XML-RPC interfacing to OpenERP is complicated and not very well documented. But, I've wrote a detailed e-book about using xmlrpc, search in Google Play for "Advanced PHP and OpenERP Interfacing Using PHP XML-RPC Library".
Regards
I am not sure in which language you want this, I am familiar with the PHP call so will explain it to you in that context.
Technically, there is no real login function. You send the API the parameters and it will respond with a user_id. And this user_id is then used when you make your next calls. Hence if you receive a user_id, 'login' was successful and you can use the user_id to proceed. If the login details were incorrect, you will receive a response stating so.
include ("../xmlrpc-3.0.0.beta/lib/xmlrpc.inc"); //the PHP XML RPC library
//GLOBAL VARIABLES
$dbname = 'database_name'; //Name of the DB you want to access
$user = 'admin'; //The user you want to 'login'
$pwd = 'admin'; //The user's password
$url = 'localhost:8069'; //The server of OpenERP
$sock = new xmlrpc_client($url."/xmlrpc/common"); //Sock files location on server
$client = new xmlrpc_client($url."/xmlrpc/object"); //client files location on server
//THE CALL
$sock_msg = new xmlrpcmsg('login'); //Type of message (all other cases use 'execute')
$sock_msg->addParam(new xmlrpcval($dbname, "string")); //1st param - Database
$sock_msg->addParam(new xmlrpcval($user, "string")); //2nd param - Username
$sock_msg->addParam(new xmlrpcval($pwd, "string")); //3rd param - password
$sock_resp = $sock->send($sock_msg); //Sends the message with parrams
if ($sock_resp->errno != 0)
{
//if there is an error
echo 'error.<br>';
}
// if your have successfully logged in, the errno == 0
elseif ($sock_resp->errno == 0)
{
//a user_id will be returned
$sock_val = $sock_resp->value();
$user_id = $sock_val->scalarval();
//YOUR NEXT CALL HERE
}
I am trying to let a contact form (Contact Form 7) on a WordPress site create new contacts in my CRM program (solve360). To make it easier, I also activated a plugin (Forms: 3rd Party Integration) in which I defined a submission url and field mapping. Part of it works, but I am missing something simple here...
When pressing the send button, the data is sent to an email address (success) and to solve360 (not yet successfully). I actually receive a message that a new contact was created in solve360, however all the fields are empty. So I am guessing the problem is that the form fields are not properly transferred to the solve360 fields. However, I am using this template from solve360:
// REQUIRED Edit with the email address you login to Solve360 with
define('USER', '****************');
// REQUIRED Edit with token, Solve360 menu > My Account > API Reference > API Token
define('TOKEN', '*****************');
// Get request data
$requestData = array();
parse_str($_SERVER['QUERY_STRING'], $requestData);
// Configure service gateway object
require 'Solve360Service.php';
$solve360Service = new Solve360Service(USER, TOKEN);
//
// Preparing the contact data
//
$contactFields = array('firstname','lastname','businessemail','businessphonedirect','name','homeaddress','cus tom10641628','custom11746174','custom13346238');
$contactData = array();
// adding not empty fields
foreach ($contactFields as $solve360FieldName => $requestFieldName) {
if ($requestData[$requestFieldName]) {
$contactData[$solve360FieldName] = $requestData[$requestFieldName];
}
}
//
// Saving the contact
//
// If there was business email provided:
// check if the contact already exists by searching for a matching email address.
// if a match is found update the existing contact, otherwise create a new one.
//
if ($contactData['businessemail']) {
$contacts = $solve360Service->searchContacts(array(
'filtermode' => 'byemail',
'filtervalue' => $contactData['businessemail'],
));
}
if (isset($contacts) && (integer)$contacts->count > 0) {
$contactId = (integer)current($contacts->children())->id;
$contactName = (string)current($contacts->children())->name;
$contact = $solve360Service->editContact($contactId, $contactData);
} else {
$contact = $solve360Service->addContact($contactData);
$contactName = (string)$contact->item->name;
$contactId = (integer)$contact->item->id;
}
if (isset($contact->errors)) {
// Email the error
mail(
USER,
'Error while adding contact to Solve360',
'Error: ' . $contact->errors->asXml()
);
die ('System error');
} else {
// Email the result
mail(
USER,
'Contact posted to Solve360',
'Contact "' . $contactName . '" https://secure.solve360.com/contact/' . $contactId . ' was posted to Solve360'
);
}
In their example, they use a contact form with method="get" instead of method="post", however in the user interface of Contact Form 7, I believe the method is fixed to "post". Could this be the problem?
Or is there a different issue? Note that an empty contact is created at the moment. I can provide field mapping details and Forms 3rd party integration does allow hooks, if that helps in anyway.
Any help would be really appreciated! Thanks.
I discovered that the action method (POST) of the 3rd party plugin was not matching the expected action method (GET) of the Solve360 script. Therefore, I had to remove the following from the script:
// Get request data
$requestData = array();
parse_str($_SERVER['QUERY_STRING'], $requestData);
and change the following piece of code from
// adding not empty fields
foreach ($contactFields as $solve360FieldName => $requestFieldName) {
if ($requestData[$requestFieldName]) {
$contactData[$solve360FieldName] = $requestData[$requestFieldName];
}
}
to
// adding not empty fields
foreach ($contactFields as $solve360FieldName => $requestFieldName) {
if ($_POST[$requestFieldName]) {
$contactData[$solve360FieldName] = $_POST[$requestFieldName];
}
}
Hope this will help someone who is connecting Contact Form 7 to their Solve360 database.