I would appreciate if anyone could guide me on the correct way on doing an ItemLookup by ISBN using the Zend Amazon Service module (with Zend 2.0).
Here is my attempt:
$query = new ZendService\Amazon\Query($appId, 'UK', $secretKey);
$query->Category('Books')->IdType('ISBN')->ItemID('978-0321784070')->AssociateTag($tag);
$result = $query->ItemLookup();
But I get the following errors:
Missing argument 1 for ZendService\Amazon\Amazon::itemLookup(), called in D:\wamp\www\site\controllers\dev.php on line 122 and defined
Undefined variable: asin
There is no way I can define the ASIN because the only information I will have is the ISBN.
I have already consulted the Zend Service Amazon user guide in the zend framework website but it is outdated and doesn't demonstrate how to do an ISBN lookup. I have also looked at the demo that came with the zend amazon package but that only details how to do item searches, not lookups.
Here is a way to get the ISBN search working, it took me a little while to get it figured out as well. The problem was that in order to search for ISBN you must use the ItemLookup method rather than the ItemSearch method which was getting set by the query() method.
There may be a better way to get this to work using the OO interface but I haven't tried that yet.
$query = new ZendService\Amazon\Query($appId, 'US', $secretKey);
$item = $query->itemLookup('9780321784070',
array('SearchIndex' => 'Books',
'AssociateTag' => $tag,
'IdType' => 'ISBN',
'ResponseGroup' => 'Small',));
Searching by ISBN should return a single ZendService\Amazon\Item object rather than an array of results. Also be aware, if you search by ISBN-13, you need to strip the - from the number or it won't find a match.
Credit to this blog post by Manas Tungare which hinted to me that we need to use IteamLookup instead of ItemSearch.
Related
I have consistent difficulty using any client service method that is not explicitly exampled somewhere. Despite following the docs and even reading the sourcecode, The class or method names I come up with following the scheme are never right.
The documentation at Packagist (see 'Making Requests") says the client library classes are autogenerated from the Google endpoints, which agrees with the description in the library's docs on Github that say the pattern for accessing methods should be "$service->resource->method(args)".
So why the following?
// works:
// I get a countable object of active classrooms owner by the specified id
$response = $this->ClassroomService->courses->listCourses([
'courseStates' => 'ACTIVE',
'teacherId' => 'me']);
// works:
// I get an instance of the single classroom's object containing lots of meta data
$response = $this->ClassroomService->courses->get( $id );
// does not work:
// 500 error, obj has no such method
$response = $this->ClassroomService->topics->listCoursesTopics( $id );
According to the API Explorer all three should be fine.
What am I missing about using client service objects?
Edit
Ultimately I determined the resource in my example to be 'courses_topics'; the method was correct per the docs. Thanks for the idea #ebram.
The question remains how the methods are named though. courseWork is my next challenge and it does not fit the the naming pattern of topics.
There is no topics member of ClassroomService.
The member is named courses_topics.
This is documented in the "Properties summary" at the bottom of the Classroom documentation.
Your code should look like this:
$response = $this->ClassroomService->courses_topics->listCoursesTopics( $id );
The documentation for Google_Service_Classroom_CoursesTopics_Resource does incorrectly give sample code where the member is named ->topics.
Given that API documentation is generated from source, but sample code is (generally) written by hand, I'll assume the API documentation is correct and the sample code is incorrect. I'd file a documentation-bug with Google.
Update:
I looked at the PHP source code for Google_Service_Classroom in GitHub and verified that the property is named courses_topics instead of topics, so in conclusion: the sample code is wrong.
What's also interesting is the resource-type in the actual source-code is Google_Service_Classroom_Resource_CoursesTopics but the documentation refers to it as Google_Service_Classroom_CoursesTopics_Resource - so that documentation is definitely wrong.
I'm trying to build a PHP RESTful service using PhalconPHP. I'm new to PHP, so this may be a beginner question. I am following a tutorial https://www.toptal.com/phalcon/phalcon-php-restful-apis, and in the tutorial there is a section where it makes a call to pull the list of users.
public static function find($parameters = null)
{
return parent::find($parameters);
}
I am passing in a list of parameters listed below.
Array
(
[conditions] =>
[bind] => Array()
[columns] => users_id
)
but I keep getting a 500 error. I'm fairly sure it has to do with how I am connecting (or in this case, NOT connecting to the database).
I'm not 100% sure on what the 'parent' part does either, nor how it connects up to my MySQL database - I think I've gotten the config setup, and I've passed in the tablename that I'm expecting it to be under, but I have no idea if it's actually connecting up and then failing, or if the call itself is failing. So far I've tried echo and print_r with as many variables as I can find, but so far I'm not getting any information on why this is failing.
What is a good way to go about troubleshooting this? How can I find out what the 'parent' is? How can I find out if I'm connecting to my database even, or if it's failing before then?
In your concrete example, the quotes are missing in your conditions and columns parameters, it should be:
$users = Users::find(
[
'conditions' => '',
'bind' => [],
'columns' => "users_id"
]
);
Which should return a list of users ids (if any).
That tutorial from Andrew Belousoff is very good but maybe the next step after Phalcon's REST tutorial, since it explains step by step the inner workings of Phalcon.
For debugging, you can also check Phalcon's guide about it: https://docs.phalconphp.com/en/3.4/debug
And after Belousoff, you can dive into deeper waters with this one: https://github.com/phalcon/phalcon-api
Error 500 means error in php, just check logs. Im not sure how this parent thing is related to phalcon. This is just OOP, you mean you are using framework without knowledge about php/oop? Parent is just parent class which you extends.
I had problem with the error from Zend Framework 1.9 when was building routers for friendly url`s. Te error was:
cannot assemble. reversed route is not specified
Was not so easy to find the solution, so i want to share if anyone will struggle with this like me.
Like they wrote in zend manual:
"Since regex patterns are not easily reversed, you will need to prepare a reverse URL if you wish to use a URL helper or even an assemble method of this class. This reversed path is represented by a string parsable by sprintf() and is defined as a fourth construct parameter:"
$route = new Zend_Controller_Router_Route_Regex(
'archive/(\d+)',
array( ... ),
array('year' => 1),
'archive/%s'
);
So basically all You have to do is to add
'archive/%s'
line to Your router params.
I found the solution in this thread
Zend community thread
This is making me crazy. I've been trying out all sorts of things but I just can't figure this out. LinkedIn's documentation is horrible...
All I need to do is simple: I need to search for a company (using a keyword) and retrieve the company id. I have issues with setting up the OAuth request and with making the request. Any advice on how to do this, especially without installing any PHP libraries?
FYI, my code: I got the OAuth.php from here.
require_once 'OAuth.php';
$base_url = 'http://api.linkedin.com/v1/company-search';
$consumer = new OAuthConsumer('mykey', 'mysecret');
$token = new OAuthToken('tokenkey', 'tokensecret');
$parameters = array (keyword => 'Apple');
$request = OAuthRequest::from_consumer_and_token($consumer, $token, "GET", $base_url, $parameters);
print_r($request);
Thanks
You're using a good OAuth library that I do recommend, but it seems to me you're missing on the Linkedin Library, or at least you haven't included the full code.
In any case, try using the simple-linkedinphp library, which uses your oauth library above. I had to use a few libraries in the past, and this is one of the best, particuarly if you're going to use Faceted search. Make sure you also check the quick start guide, it will help you a lot, as well as the class reference. The company search API function could be found here.
You could always use the raw() function for any custom calls not supported by the above function. I had to use that for some calls.
I wish to call a web service, using SOAP, from PHP (using the included SOAP extension). The web service in question is http://www.webservicex.net/CurrencyConvertor.asmx
Now the Currency type is an enum, and I cannot figure out how to work with these in PHP in order to be able to call the 'ConversionRate' function. I know I have to do something with a class map, but I can only find limited and unhelpful information on this topic. Can anyone help? A working example maybe?
Thanks!!!!
The enum here only defines legitimate values, that is your data type is actually a string of one of those values.
Here's some psuedo-code to get you on your way:
$from_currency = "AFA";
$to_current = "ALL";
$soap_handler->ConversionRate($from_currency, $to_currency);
$exchange_rate = $soap_handler->response();