All i'm trying to get the items reviews from amazon using Net::Amazon::Attribute::Review
I have tried everything in my low knowledge of perl to try to get it to work but I can't seem to get it. Any help would be appreciated.
DESCRIPTION
Net::Amazon::Attribute::Review holds customer reviews.
Net::Amazon::Attribute::Review - Customer Review Class
SYNOPSIS
use Net::Amazon::Attribute::Review;
my $rev = Net::Amazon::Attribute::Review->new(
'rating' => $rating,
'summary' => $summary,
'content' => $content,
'asin' => $asin,
'customer_id' => $customer_id,
'date' => $date,
'helpful_votes' => $helpful_votes,
'total_votes' => $total_votes,
);
It looks like you are pointing to a sub-package being part of Net-Amazon-0.62.
Reading the README, you can find some request example and Net::Amazon::Attribute::Review is one of the attributes of the response.
Digging into the source code of the Response serialization, the object Review is parsed from xml here https://metacpan.org/source/BOUMENOT/Net-Amazon-0.62/lib/Net/Amazon/Response.pm#L123-129 .
If you want to debug the content of the response, you can call the method as_string.
You can find a full example of fetching reviews inside the library in this file:
https://metacpan.org/source/BOUMENOT/Net-Amazon-0.62/eg/reviews
Related
Apologies for posting what seems to be an oft-asked question but I have toiled for two days without getting closer.
I am running Rails 4.0.1 (with Devise, CanCan, among others) and have user and role models with a HABTM users_roles table (as created by the since-removed rolify).
class Role < ActiveRecord::Base
has_and_belongs_to_many :users, :join_table => :users_roles
belongs_to :resource, :polymorphic => true
attr_reader :user_tokens
def user_tokens=(ids)
self.user_ids = ids.split(",")
end
end
My submitted form data is:
"role"=>{"name"=>"disabled", "resource_id"=>"", "resource_type"=>"Phone", "user_tokens"=>["", "3"]}
(Not sure where the empty string comes from; it's not in the option list, but hey, welcome to Rails).
My problem is with getting the user_tokens data passed into the appropriate variable in the controller.
There are lots of postings suggesting the correct format (e.g., how to permit an array with strong parameters)
If I specify the permitted parameters thus:
params.require(:role).permit(:name, :resource_id, :resource_type, :user_tokens => [] )
I get a '500 Internal server error' with no other details.
If I specify the permit as
params.require(:role).permit(:name, :resource_id, :resource_type, user_tokens: [] )
I don't get any errors (No unpermitted parameters in the dev log) but the user_tokens array is not passed through in the #role.
If I run this scenario through a console I get:
params = ActionController::Parameters.new(:role => {:resource_id => "", :resource_type => "Phone", :user_tokens => ["", "3"]})
params.require(:role).permit(:name, :resource_id, :resource_type, user_tokens: [] )
=> {"resource_id"=>"", "resource_type"=>"Phone", "user_tokens"=>["", "3"]}
params.require(:role).permit(:user_tokens).permitted?
Unpermitted parameters: resource_id, resource_type, user_tokens
=> true
I'm stuck as to where I should try looking next.
Even though I was sure I had already tried it, changing the model to be
def user_tokens=(ids)
self.user_ids = ids
end
fixed it. I've always struggled to understand this bit of notation except when I've spent 4 days trying why my many:many models don't work.
I guess it'd be easier if I was doing this full time rather than just for particular sysadmin projects.
I want to keep track of all triggered emails by the application into a db table, so that i can have a log which emails are sent and to whom.
Kindly suggest me the best possible solution.
I have solved this using the following way:
created a class in lib directory
class MyProjectMailLogger
def self.delivering_email(message)
#to = message.to.to_s
#subject = message.subject.to_s
#message = message.body.to_s
EmailQueue.create!(:receipient_email => #to, :subject => #subject, :message => #message, :email_status_id => 3)
end
end
In config/initalizers/setup_mail.rb
ActionMailer::Base.register_interceptor(MyProjectMailLogger)
You might need to add the following line in the application.rb file as its not include files from lib directory:
config.autoload_paths += %W(#{config.root}/lib)
Yay!! and i logged my emails.
I am doing some research on this and it seems like https://github.com/ankane/ahoy_email is a nice gem to accomplish this. It uses an interceptor internally like the accepted answer. It also integrates with a free event tracking library that has a number of different backends. Might be something to consider if you're starting something like this today.
On Magento 1.7 SOAP APIv2, i'm looking for a way to get a date range to retrieve information from the SOAP API.
$complexFilter = new filters();
$complexFilter->complex_filter = array(
array(
'key' => 'created_at',
'value' => array('key' => 'from', 'value' => '2012-12-17 00:00:00')
),
array(
'key' => 'created_at',
'value' => array('key' => 'to', 'value' => '2013-01-21 12:02:02')
),
);
This seemed like the most natural approach, but only the last criterion gets used. I also tried other combinations like a complex filter of complex filters, different ways to combine them, using gt and alike instead of from and co. Most of these approaches resulted in the same result: only the last criterion inside will be used.
What is the proper way to get a date range via the API? Can this also be done via a regular filter? If so, how to combine the start and end date?
I found a better way looking at the code in Magento!
Luckily it IS CASE SENSITIVE, so:
$complexFilter->complex_filter = array(
array(
'key' => 'CREATED_AT',
'value' => array('key' => 'from', 'value' => '2012-12-17 00:00:00')
),
array(
'key' => 'created_at',
'value' => array('key' => 'to', 'value' => '2013-01-21 12:02:02')
),
);
does the trick pretty neatly!
After googling a lot more i finally come to some explanation.
Obviously, the implementation of the complex filters does not allow more then one attribute to be present. This is also what I noticed during my tests: only the last attribute used influences the result. I therefore need to find another way of doing what I want. It's somehow sad to see that Magento does not provide an easy way to do this with ther SOAP API.
The final approach I used now is to determine a date that comes closest to what I want. Then just iterate through the results that that are in the daterange I want. This way (at least with our product data), I keep the load and results to a minumum and still get the desired products.
edit seems like the original link is down and the site doesn't exist anymore. The text above should be enough information. The blog merely showed some code examples with the faulty implementation.
Seems to be a bug in mage\sales\order\api\v2.php
Matlock provides a possible solution for this in the comment section of this thread: http://www.magentocommerce.com/bug-tracking/issue?issue=8073
I am able to post to a users feed using a URL from my app, for example:
https://graph.facebook.com/USER_ID/feed?
link=https://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&
name=Facebook%20Dialogs&
caption=Reference%20Documentation&
description=Using%20Dialogs%20to%20interact%20with%20users.&
message=Facebook%20Dialogs%20are%20so%20easy!
According to the documentation here: https://developers.facebook.com/docs/reference/dialogs/feed/ it is possible to add "actions" which appear next to the Like and Comment buttons under each post. The documentation states the actions must be in a JSON format with object with keys name and link
Well, you could add actions parameter. If in PHP then you could do like:
'actions' => json_encode( array(
'name' => 'Some sample link example',
'link' => 'http://something.com/test/'
)),
Did you mean something like that.
Hope it helps
I have my app posting a link to the user's wall if they have given it permissions, but it ignores the picture, name, and caption values I pass along with it.
HTTParty.post("https://graph.facebook.com/#{#sponsorship.fbid}/links", :query => {:access_token => URI.escape(#access_token), :link => URI.escape(request.env['HTTP_HOST']), :picture => URI.escape("#{request.env['HTTP_HOST']}/images/fb_post/after_donation.jpg"), :name => URI.encode("Click here"), :caption => URI.encode("This is the caption")})
Any help is appreciated, thanks.
Think you might need to be using
https://graph.facebook.com/#{#sponsorship.fbid}/feed
instead of
https://graph.facebook.com/#{#sponsorship.fbid}/links
It's probably taking those values from the open graph meta tags on the link target rather than the ones you provide at post time. Not sure if that's supposed to be happening but you should check if your link has the correct tags.
https://developers.facebook.com/docs/opengraph/ is the docs and https://developers.facebook.com/tools/debug will show you what markup is detected on your page