I'm trying to get mailchimp integrated with my ruby-on-rails app using the Gibbon gem.
I've successfully accessed the API. I tested it by getting a list of all my mailchimp lists. However, I'm running into problems with the listsubscribe method. I'm not getting any errors, it just isn't working at all.
I have the following code in the controller for the page where users sign up, after the user is made and their information can be accessed.
gb=Gibbon::API.new
gb.listSubscribe({:id => "the-id-for-list", :email_address => user.email, :update_existing => false, :double_optin => false, :send_welcome => true, :merge_vars => {'FNAME' => user.first_name, 'LNAME' => user.last_name, 'MERGE3' => user.subscription, 'MERGE4' => DateTime.now}})
It does nothing. I've tried playing around with the parameter phrasing (à la this post:How do you use the Gibbon Gem to automatically add subscribers to specific interest groups in MailChimp?) I've tried structuring it more like in this tutorial: http://www.leorodriguez.me/2011/08/subscribe-member-into-mailchimp-using.html
I have no idea what's going wrong. As I said before, other API calls are going through to MailChimp. Do you have any suggestions? Thank you in advance.
It turns out I had the code in the wrong place. I was not putting it where users were actually being created, but in the code to generate the view to ask users to sign up. Once I moved it to where the user was actually created, it worked fine.
Related
Was any breaking change made by Google on GMail API on 11th April, 2020 ?
We have a ruby web application which also has a Chrome extension. (pretty old, ruby 2.1.0) which uses google-api-client version 0.6.4 and was working great so far, but then since April 11, the app stopped working in a way that all the call to GMail APIs are failing with 404 error.
To give a clue, we have a library from where we call google client to perform actions, something like this:
def thread_metadata(id)
#metadata ||= execute(gmail_api.users.threads.get,
{
'collection' => 'public',
'userId' => 'me',
'id' => id,
'format' => 'metadata',
'metadataHeaders' => 'Subject'
}
)
However, the response which we get from Google is 404 with a message something like this:
he requested URL /discovery/v1/apis/gmail/v1/gmail/v1/users/me/threads/16365500056684b0?collection=public&format=full was not found on this server. That’s all we know.
I don't have any clue what has gone wrong except that the 404 error which started coming in suddenly since April 11.
You'll need to update your google-api-client gem, as of v0.8.6 they changed where the baseUrl is to make requests. Presumably the path the old gems were still using remained unchanged until recently.
The method_base used to generate the URI returns something different pre-0.8.6:
irb(main):046:0> gmail_api.method_base
=> #<Addressable::URI:0x3ff4ff4e319c URI:https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest>
In 0.8.6+:
irb(main):009:0> gmail_api.method_base
=> #<Addressable::URI:0x3ff97faf4610 URI:https://www.googleapis.com/>
Now I wish to build a login function with Wykop.pl API.
Can anybody help me to setup the thing?
As of now, I don't even have clue how to fill the
'scope' => array()
not to mention which privileges I should enable when connecting my app to wykop.pl
'Wykop' => array(
'client_id' => '423423',
'client_secret' => '0XMRI423423BfDFG',
'redirect_url' => 'http://www.appname.pl/dashboard',
'scope' => array('login', 'klucz_polaczenia','profile'),
),
This is a SDK for the site https://github.com/p1c2u/wykop-sdk
Unfortunately, as for now I am unable to translate the code into sth useful to me.
For the purpose of o-auth login, should scope include 'login' and 'klucz_polaczenia' ?
After the function is done, it would be a good idea to add the example to
this project repository of examples:
https://github.com/Lusitanian/PHPoAuthLib/tree/master/examples
Edit:
Wykop is not using o-auth... so the package I was trying to use is of no value.
Any help appreciated.
Edit 2:
The clostest I got to my goal is using this repo:
https://github.com/matiit/wkop
I did this recently. I'm using following workflow:
Display the login form to the user, with redirect set to callback.
Check the signature of callback, if correct then proceed.
Check, if I can login on Wykop.pl with received token, if so, then proceed.
Check, if user exists in my database, if so, I login him, if not, I create and login him.
Whole process of connecting with Wykop.pl API is available here: http://www.wykop.pl/dla-programistow/dokumentacja/#info6_7_5
Everything in my Magento store is working ok, except for a route I created that calls the API:
$proxy = new SoapClient('SOAPCLIENTURL');
$sessionId = $proxy->login('USERNAME', 'PASSWORD');
$proxy->customerCustomerCreate($sessionId, array(
'email' => $email,
'firstname' => '',
'lastname' => '',
'password' => $password,
'website_id' => 7,
'store_id' => 7
));
When I comment out these lines, the route works fine. Any ideas why this 503s the page and how to fix it?
The code block that's causing your problem is a request to an external API that could fail for numerous reasons. The way you'd fix this is to monitor your server and Magento error and exception logs for errors, take a look at the error, and then fix the problem (or post the specific error to a site like this and ask for help).
You could also try running the above code snippet outside of a Magento context (in a stand along script) and see what sort of error you get.
If errors aren't showing up then you need to research how to setup your system for proper error handling.
Also, if you're setting up a Magento route and making an API call into the same system, there's no reason to use the SOAP or XML-RPC layer. Each Magento API section has a corresponding PHP object that contains all the logic. The above method is equivalent to
Mage::getModel('customer/customer_api_v2')->create(array(...));
With the real PHP class being at
app/code/core/Mage/Customer/Model/Customer/Api/V2.php
and the create method defined at
app/code/core/Mage/Customer/Model/Customer/Api.php
Let me preface this by saying most of this application is a giant hack put together in a short window of time under pressure so I may have deeper issues. This question will likely have some bad code in it.
I've built a Sinatra application to handle some tasks with purchase and sales orders in-house. Part of that is to send a few parameters to one of the routes in the app which will then push those off to an API that does useful things with them.
Right now, I'm generating the links with paramaters from within a pretty ugly loop in HAML:
%td
- opts = JSON.generate({ "key" => d[d.keys.first]["key"], "sa_id" => d.keys.first, "site" => d[d.keys.first]["site"], "name" => d[d.keys.first]["name"], "recipient" => d[d.keys.first]["email"], "items" => d[d.keys.first]["descriptions"], "date" => d[d.keys.first]["ship_date"]})
-if (d[d.keys.first]["email"]) && (d[d.keys.first]["site"] != "")
%a{:href => "/notify?options=#{opts}", :title => "Deliver"} Deliver
-else
Deliver
%a{:href => "/destroy?key=#{d.keys.first}", :title => "Destroy"} Destroy
When clicking hte "deliver" link (%a{:href => "/notify?options=#{opts}", :title => "Deliver"} Deliver) locally, everything behaves as expected. My /notify route is called, it hands the parameters off to the desired API, and everything is rainbows and unicorns. When I click that same link on Heroku, it throws a "Bad Request" stating "Bad URI". The only difference between the two URLs generated is the hostname (localhost:3000 vs. myapp.herokuapp.com) and vimdiff confirms this.
Everything else being even, why would Heroku (using Webrick) kick back my URI when my local instance (Thin) doesn't seem to care?
Switching from Webrick to Thin on Heroku resolved this issue, though I'm not sure about the specifics as to why.
We've had some issues where development and production environments that were seemingly identical behaved differently once deployed on heroku. A quick sanity check I like to do is to diff the local gemfile.lock to the one on heroku after the deploy process is complete. I know - we should lock our gem versions down more tightly and we will do, so don't consider this a best practice - but it unearthed some hard to track down issues, some of which were related to the fact that we have some devs on Windows and some on Mac and the gemfile.lock often had Windows specific gems which causes issues on heroku. Just something to consider.
I have found some really sparse documentation about the options for posting to your feed.
I am trying to post to "/me/feed" and then include a user in that post. I am trying to re-create the way that you can now do #username in the Facebook Status box, but from the API instead.
Using the Ruby OAuth2 lib I to do the following.
OAuth2::AccessToken.new(FBOAuthClient,fb_token).post("/me/feed", :message => status)
Which is great, but I want to do something like:
OAuth2::AccessToken.new(FBOAuthClient,fb_token).post("/me/feed", :message => status, :to => FUID)
Is this possible?
Or can, I post directly with JSON?
Thanks,
Kent
there still seems to be an open bug preventing this. http://bugs.developers.facebook.net/show_bug.cgi?id=12074