How to get book title from ISBN with Knowledge Graph? - php

I volunteer in a communal library and I'm in charge of the digital transition.
I'm using the free and open-source software PMB and I want to automate the retrieval of book titles with the Knowledge Graph API (which is not possible with PMB, or I missed something).
Why to use Knowledge Graph instead of ISBNdb or another free ISBN API ? Because none is as complete and qualitative as KG.
For example: I take the ISBN of a French book : 9782884613736 ("Le foot illustré de A à Z").
Not found on ISBNdb.com, etc.
So, on when I google it, the Knowledge Graph returns me exactly what I want :
> Screenshot of what I see
But when i'm using the API :
GET https://kgsearch.googleapis.com/v1/entities:search?languages=fr&query=9782884613736&types=Book&key={YOUR_API_KEY}
{
"#context": {
"#vocab": "http://schema.org/",
"goog": "http://schema.googleapis.com/",
"EntitySearchResult": "goog:EntitySearchResult",
"detailedDescription": "goog:detailedDescription",
"kg": "http://g.co/kg"
},
"#type": "ItemList",
"itemListElement": [
]
}
Nothing returned to my GET request. (It works properly if I request the book title, it returns well the informations)
I tried with different types according to schema.org : Book, BookSeries, BookFormatType.
Is there a way to use KG API as I want ?
I'm totally open to all suggestions (even to use another method to reach my aim).
Thank you.

The ISBN seems to be wrong or doesn't exits on google DB, here's a sample using google books api:
ISBN_10 : 2884610154
https://www.googleapis.com/books/v1/volumes?languages=fr&q=isbn:2884610154
ISBN_13 : 9782884610155
https://www.googleapis.com/books/v1/volumes?languages=fr&q=isbn:9782884610155

Related

CODE - UC SEG STATUS NOT ALLOWED Sabre error occurs when I try to Book fligth segment using Create Passenger Name Record API?

I am trying to create Passenger Name Record using Create Passenger Name Record API of Sabre. But When I pass information fetched from BargainFinderMax API to Passenger Name Record API, It gives the following error. It happens in some requests.
Please find below my Request Sample Flight segment part
"OriginDestinationInformation":{
"FlightSegment":[
{
"Status":"NN",
"MarriageGrp":"O",
"FlightNumber":"206",
"NumberInParty":"2",
"OriginLocation":{
"LocationCode":"JFK"
},
"ArrivalDateTime":"2018-09-15T22:10:00",
"MarketingAirline":{
"Code":"EK",
"FlightNumber":"206"
},
"ResBookDesigCode":"U",
"DepartureDateTime":"2018-09-14T22:20:00",
"DestinationLocation":{
"LocationCode":"DXB"
}
},{
"Status":"NN",
"MarriageGrp":"I",
"FlightNumber":"604",
"NumberInParty":"2",
"OriginLocation":{
"LocationCode":"DXB"
},
"ArrivalDateTime":"2018-09-16T05:30:00",
"MarketingAirline":{
"Code":"EK",
"FlightNumber":"604"
},
"ResBookDesigCode":"U",
"DepartureDateTime":"2018-09-16T02:30:00",
"DestinationLocation":{
"LocationCode":"KHI"
}
}
]
}
Below is the response with error that I receive from the API.
{"CreatePassengerNameRecordRS":{"ApplicationResults":{"status":"NotProcessed","Error":[{"type":"BusinessLogic","timeStamp":"2018-09-11T08:45:51.946-05:00","SystemSpecificResults":[{"Message":[{"code":"ERR.SWS.HOST.ERROR_IN_RESPONSE","content":"Unable to perform air booking step"}]}]}],"Warning":[{"type":"Application","timeStamp":"2018-09-11T08:45:51.946-05:00","SystemSpecificResults":[{"Message":[{"code":"WARN.SP.PROVIDER_ERROR","content":"EnhancedAirBookRQ: CODE - UC SEG STATUS NOT ALLOWED-0003"}]}]}]}},"Links":[{"rel":"self","href":"https://api.test.sabre.com/v2.1.0/passenger/records?mode=create"},{"rel":"linkTemplate","href":"https://api.test.sabre.com//passenger/records?mode="}]}
could you please guide me why this happens. please also note that I am sending this request from PHP using CURL. In some cases booking is successfully completed.
Thanks in advance.
This is normal, but the rate of getting is UC code should be less than 10%.
Possible reasons could be
Your PCC is blocked. Which is not the case with you because you are not getting this code on all requests.
The airline when you are booking becomes unavailable or the seat is taken before you confirm your PNR
The issue also comes in some coshare flights where partnered airlines have some issues
This is normal behavior and depends on the flights you use, at the moment of booking them they may not be available anymore. cURL and PHP do not affect this in any way. Are you obtaining this flight combination from BFM or an availability request?
As this workflow is notorious unstable, i recommend you using the SOAP Enhanced Airbook + Passenger Details. I have not heared of anybody that is using create PNR in production yet.

Specification of mark-up format included in facebook open graph text

When I am performing Open Graph requests, some of the responses that I am expecting to be text are having some kind of markup included. For example, when I am requesting the Name and Description of an album, in the description I get something like \u0040[12412421421:124:The Link]. (The \u0040 is actually the # sign.)
In this case it seems that what it is saying is that the 'The Link' should be a hyperlink to a facebook page with ID 12412421421. I presume there is similar kind of markup for hashtags and external URLs.
I am trying to find some official documentation or description for this, but I can't seem to find any documentation of this (I might be looking with the wrong keywords).
Is there any online documentation that describes this? And better still is there an PHP library or function already available somewhere that converts this text into its HTML equivalent?
I am using this Facebook PHP SDK, but it doesn't seem to offer any such function. (Not sure if there is anything in the new version 4.0 one but I can't use it anyway for now because it requres PHP 5.4+ and my host currently is still on 5.3.).
It's true that the PHP SDK doesn't provide anything to deal with these links and the documentation doesn't document that either. However the API gives all the information you need in the description field itself, so here is what you could do:
$description = "Live concert with #[66961492640:274:Moonbootica] "
. "in #[106078429431815:274:London, United Kingdom]! #music #house";
function get_html_description($description) {
return
// 1. Handle tags (pages, people, etc.)
preg_replace_callback("/#\[([0-9]*):([0-9]*):(.*?)\]/", function($match) {
return ''.$match[3].'';
},
// 2. Handle hashtags
preg_replace_callback("/#(\w+)/", function($match) {
return ''.$match[0].'';
},
// 3. Handle breaklines
str_replace("\n", "<br />", $description)));
}
// Display HTML
echo get_html_description($description);
While 2. and 3. handle hashtags and breaklines, the part 1. of the code basically splits up the tag #[ID:TYPE:NAME] into 3 groups of information (id, type, name) before generating HTML links from the page IDs and names:
Live concert with Moonbootica in London, United Kingdom! #music #house
Live concert with Moonbootica in London, United Kingdom!
#music #house
FYI and even if it's not much useful, here are the meanings of the types:
an app (128),
a page (274),
a user (2048).
the # describes a tag to someone,facebook id doesnt make difference between a fanpage or a single person so you gotta deal with php only.and the # should be the only char that describes a person/page tagged
The markup is used to reference a fanpage.
Example:
"description": "Event organised by #[303925999750490:274:World Next Top Model MALTA]\nPhotography by #[445645795469650:274:Pixbymax Photography]"
The 303925999750490 is the fanpage ID. The World Next Top Model MALTA is the name of fanpage. (Don't know what the 274 means)
When you render this on your page, you can render like this:
Event organised by World Next Top Model MALTA
Photography by Pixbymax Photography

Get my Apps Data iTunes Connect

I'm looking for a script or series of scripts that download and parse iTunes Connect sales data and AppStore comments, ratings and rankings data for a defined app. I want to get my apps data on my web site .
You can do this by making following request in PHP
$response = file_get_contents("https://itunes.apple.com/lookup?id={YOUR_APP_ID}&entity=software");
For Example:
$response = file_get_contents("https://itunes.apple.com/lookup?id=317469184&entity=software");
Will give following JSON output:
{
"resultCount":1,
"results": [
{
"kind":"software", "features":[],
"supportedDevices":["iPad23G", "iPhone5s", "iPad2Wifi", "iPhone5c", "iPadThirdGen", "iPadFourthGen4G", "iPhone4", "iPadMini", "iPadThirdGen4G", "iPadFourthGen", "iPhone5", "iPodTouchFifthGen", "iPadMini4G", "iPhone4S"],
"isGameCenterEnabled":false,
"screenshotUrls":["http://a2.mzstatic.com/us/r30/Purple/v4/25/c1/45/25c145d7-5272-4f41-536f-c5744cd0c61e/screen1136x1136.jpeg", "http://a4.mzstatic.com/us/r30/Purple/v4/61/3c/0c/613c0c2e-1263-c54c-8658-2de8e6a0dd4b/screen1136x1136.jpeg", "http://a5.mzstatic.com/us/r30/Purple/v4/fa/19/ad/fa19ad92-85cc-c4bf-921b-f575a543327c/screen1136x1136.jpeg", "http://a1.mzstatic.com/us/r30/Purple4/v4/3d/5d/97/3d5d9701-f6d9-cc12-7e91-b9ede19e9776/screen1136x1136.jpeg", "http://a2.mzstatic.com/us/r30/Purple6/v4/52/cc/ee/52cceed3-5837-9987-4c10-7cd02bf33b1e/screen1136x1136.jpeg"], "ipadScreenshotUrls":[], "artworkUrl60":"http://a1156.phobos.apple.com/us/r30/Purple2/v4/54/93/ac/5493acfd-1a6e-7960-dda5-7de005232d35/AppIcon57x57.png", "artworkUrl512":"http://a1105.phobos.apple.com/us/r30/Purple4/v4/95/77/8b/95778b7e-8897-3b68-b8f9-134f34531b25/mzl.sobbgbbg.png", "artistViewUrl":"https://itunes.apple.com/us/artist/espn/id317469187?uo=4", "artistId":317469187, "artistName":"ESPN", "price":0.00, "version":"4.0.5",
"description":"Introducing the all-new SportsCenter app, a supercharged update to the popular ScoreCenter app packed with live scores, breaking news, video highlights, in-depth analysis, personalized alerts and more. What more could any sports fan ask for? \n\nFeatures include: \n- Instant scores and updates on the biggest games of the day as well as your favorite teams \n- Breaking news and analysis across hundreds of leagues and teams, all powered by ESPN's authoritative newsroom \n- Dozens of notification options: never miss another kickoff, scoring play, substitution, final whistle or tidbit of breaking news \n- Add, edit and remove favorite teams quickly and easily for a customized experience throughout \n- Deep Twitter integration for a social perspective on news, rumors and gossip", "currency":"USD", "genres":["Sports", "Entertainment"], "genreIds":["6004", "6016"], "releaseDate":"2009-06-02T07:00:00Z", "sellerName":"ESPN Inc.", "bundleId":"com.espn.ScoreCenter", "trackId":317469184, "trackName":"ESPN SportsCenter", "primaryGenreName":"Sports", "primaryGenreId":6004,
"releaseNotes":"- In-game highlights added to game pages during the Live game\n- SportsCenter TV Graphics now inside the app\n- Support for World Cup videos and games\n- Easily share video right from the News Feed\n- Improved performance \n- Enhanced design\n- The latest Breaking News", "minimumOsVersion":"7.0", "formattedPrice":"Free", "wrapperType":"software", "trackCensoredName":"ESPN SportsCenter", "languageCodesISO2A":["NB", "DA", "NL", "EN", "FR", "DE", "IT", "NN", "ES"], "fileSizeBytes":"18953341", "sellerUrl":"http://www.espn.com", "contentAdvisoryRating":"4+", "averageUserRatingForCurrentVersion":3.5, "userRatingCountForCurrentVersion":4317, "artworkUrl100":"http://a1105.phobos.apple.com/us/r30/Purple4/v4/95/77/8b/95778b7e-8897-3b68-b8f9-134f34531b25/mzl.sobbgbbg.png", "trackViewUrl":"https://itunes.apple.com/us/app/espn-sportscenter/id317469184?mt=8&uo=4", "trackContentRating":"4+", "averageUserRating":3.5, "userRatingCount":264216
}
]
}
Reference Link

Google Analytics API Filter By ga:campaign

I need to filter results by ga:medium & ga:campaign.
I can bring data with ga:medium filter but not with ga:campaign.
Sample Code:
$query->setStartDate(new \DateTime('-1week'));
$query->setEndDate(new \DateTime());
$query->setMetrics(array('ga:bounces'));
$query->setDimensions(array('ga:day', 'ga:medium', 'ga:campaign'));
$query->setFilters(['ga:medium=='.$medium, 'ga:campaign=='.$campaign]);
Edit:
When i use "segments", i'm getting some data but i'm not really sure what.
$query->setSegment('sessions::condition::ga:campaign=='.$campaign);
Question 2: If i want to get the data of "clicks" for that exact medium and campaign, should i use bounce or something else?

Generate zip code based on City and State with Google API

Would there be a way to do a zip code lookup based on City/State input in a form? I'm thinking the Google geocode API might be the right direction. Any thoughts? I have a site built on Wordpress so the code would have to utilize PHP. Thanks in advance.
YQL can do things like this:
select name from geo.places.children where parent_woeid in (select woeid from geo.places where text="sunnyvale, usa" limit 1) AND placetype = 11
returns:
{
"query": {
"count": 6,
"created": "2011-03-16T06:49:09Z",
"lang": "en-US",
"results": {
"place": [
{
"name": "94086"
},
{
"name": "94087"
},
{
"name": "94088"
},
{
"name": "94089"
},
{
"name": "94090"
},
{
"name": "94085"
}
]
}
}
}
YQL Console
There are examples on there on how to implement queries like this in both PHP and Javascript on their site.
Geocoding is where you find the coordinates of an address. Yes you could geocode a city,state but this would give you he center of the city (as defined by the geocoder's internal database - typically a centroid or 'city hall'.
Most cities have multiple zip codes: Do you want all of these?
Similarly a zip code could contain multiple cities - especially in rural areas where zip codes can be large and cities are what other countries would call 'villages' and 'hamlets'
So you best bet is probably to get a database. There might be some free ones around (Geonames comes to mind but I don't think it has zip codes), but you might end up having to buy one.
First a note on the Google API: be aware of Google's TOS so you don't take a wasted path as others have done (sometimes unknowingly). Specifically: "Note: the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited.".
Your best bet is to get a free zip code database if your project is not mission-critical; otherwise, you'll probably need a good commercial-grade database. Just google "commercial grade zip code database".
Also, see a good stack-overflow thread about this topic.

Categories