Symfony ivory google map photos url - google-maps

I want to display a photo of a google place. I'm using below code to get the information about a place
$request = new PlaceDetailRequest($placeID);
$response = $this->container->get('ivory.google_map.place_detail')->process($request);
Its Working fine.
With $response->getResult()->getPhotos()[0]->getReference() I get the reference to the first photo.
Now to get the real URL of this photo I have to call
https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=PHOTOReference&key=YOUR_API_KEY
To get this I using below code
$requestPhoto = new PlacePhotoRequest($placeID);
$responsePhoto = $this->container->get('ivory.google_map.place_photo')->process($requestPhoto);
and get below error:
You have requested a non-existent service "ivory.google_map.place_photo". Did you mean this: "ivory.google_map.place_detail"?
Can anybody help me? Or: How can I get the URL on a different way?

OK, found the problem: It was a misconfiguration of the config.yml. I had an empty line before 'place_photo'
ivory_google_map:
place_detail:
client: httplug.client.default
message_factory: httplug.message_factory.default
format: json
api_key:
place_photo:

Related

IMPORTXML- Could not fetch URL

I am trying to scrape data from wine-searcher.com and am having an issue with IMPORTXML in google sheets, I keep getting the "could not fetch url" error when trying either of the following:
=IMPORTXML("https://www.wine-searcher.com/find/robert+mondavi+rsrv+cab+sauv+napa+valley+county+north+coast+california+usa","//h1")
=IMPORTXML("https://www.wine-searcher.com/find/robert+mondavi+rsrv+cab+sauv+napa+valley+county+north+coast+california+usa","//*[#id='tab-info']/div/div[1]/div[2]/div/div[1]/span[2]/span[2]") ( xpath to scrape current average price)
I've tried suggestions in other stack posts such as with/out http/s, www, and both XPath and full XPath to no avail. I have also tried with other URLs and they work no problem, maybe the problem is with URL length or format? Any help would be appreciated. If it cannot be done with IMPORT XML, any free alternatives suggested?
As the page is built in javascript on the client side and not on the server side, you will not be able to retrieve the data by the importxml / importhtml functions. However, the page contains a json which you can retrieve and analyze to retrieve the information you need.
function myFunction() {
var url = 'https://www.wine-searcher.com/find/robert+mondavi+rsrv+cab+sauv+napa+valley+county+north+coast+california+usa'
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.split('<script type="application/ld+json">')[1].split('</script>')[0]
var data = JSON.parse(jsonString)
Logger.log(data)
}
all these informations are available, from x=0 to x=23
data.offers[x].#type
data.offers[x].priceCurrency
data.offers[x].availability
data.offers[x].priceValidUntil
data.offers[x].url
data.offers[x].name
data.offers[x].seller.#type
data.offers[x].seller.name
data.offers[x].seller.description
data.offers[x].seller.availableDeliveryMethod
data.offers[x].seller.address.#type
data.offers[x].seller.address.addressRegion
data.offers[x].seller.address.addressCountry.#type
data.offers[x].seller.address.addressCountry.name
data.offers[x].priceSpecification.#type
data.offers[x].priceSpecification.description
data.offers[x].priceSpecification.price
data.offers[x].priceSpecification.priceCurrency
https://docs.google.com/spreadsheets/d/17f6lhaHA_xpSWClzxkYZcNs4FeM4VHA480QrmwyJvT4/copy
as mentioned both these basic formulae return nothing:
=IMPORTXML("https://www.wine-searcher.com/find/robert+mondavi+rsrv+cab+sauv+napa+valley+county+north+coast+california+usa"; "//*")
=IMPORTDATA("https://www.wine-searcher.com/find/robert+mondavi+rsrv+cab+sauv+napa+valley+county+north+coast+california+usa")
pls note that importing data into spreadsheet is URL specific, so if something works well for www.aaa.org most likely it wont work for www.bbb.org

Wordpress REST API search products

Hope that you can help me.
I have a website that runs wooccommerce. I am using the woocommerce rest api. Now on another website what I want to do is create a simple search field where I type something and the search form needs to search through the woocommerce website and return results.
Is there a way I can achieve that ?
Try this:
/wp-json/wc/v2/products?search={{product_name}}
Works for me.
I think no.
The New Version of WooCommerce API (v2) is supports id based calls.
so instead you can get a list of abstract product details in your 2nd website and call back via product id.
/wp-json/wc/v2/products?search={{product_name}}
Is this function working if you are looking a exact product?
If you have a product like MR2050 and another with MR2050K, the result is not as you may expected, cause API rest will return 2 products, not just ONE?
If you use a wc-api-php (PHP library), please follow like this :
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'http://mydomain', // Your store URL
'ck_****', // Your consumer key
'cs_****', // Your consumer secret
[
'wp_api' => true, // Enable the WP REST API integration
'version' => 'wc/v3' // WooCommerce WP REST API version
]
);
echo "<pre>";
print_r($woocommerce->get('products', ['search' => 'key word']));
echo "</pre>";
This works for me in 2021:
/wp-json/wc/v3/products?search={{productName}}
productName - refers to the input that you enter in the Search box

How do i get data from a webpage using google apps script?

i looked the existing questions (such as this one: Get data from webpage using Google Apps Script and Yahoo Query Language) which are similar to my query but had no luck.
How do i get data from bseindia.com using UrlFetchApp? Here is the page: http://www.bseindia.com/stock-share-price/stockreach_financials.aspx?scripcode=532343&expandable=0
Now, for example, How do i get the Revenue of Dec 14 from the above page? In this case, the code should return 2,652.91.
i tried this:
function getit(){
var response = UrlFetchApp.fetch("http://www.bseindia.com/stock-share-price/stockreach_financials.aspx?scripcode=532343&expandable=0");
var cut = response.substring(str.indexOf("<td class=TTRow_right>"),response.length);
var value = cut.substring(0, cut.indexOf("</td>"));
Logger.log(number);
}
The error i get is:
TypeError: Cannot find function substring in object
what i am doing is definitely not correct also because every revenue number in there starts with the same "td class=TTRow_right"
The response you are getting is not a string but of type HTTPResponse, so you cannot use substring(..) on it.
Try response.getContentText()
you find more details here http-response

How to use ReplaceRows from .NET Google.Apis.Fusiontables.v2 (stream csv)?

Goal: to update a Fusion Table by replacing old rows by new ones from a csv file without headers using ReplaceRows().
I am using the Google.Apis.Fusiontables.v2 library.
I have read and reread the documentation, but still can`t get my code working.
Authentication is working and I am able to perform simple INSERTs without issue:
string sql = "INSERT INTO 11t9VLt3vzb46oGQMaS2LTSPWUyBYNcfi1shkmvag (rpu_id, NO_BAIL, 'Usage (description)', 'Use (description)', 'Sup. louable m2', 'Sup. Utilisable m2', 'SumTotal Lou', 'Percent Lou', 'SumTotal Util', 'Percent Util') VALUES (9999,1111,'Test','Test En',1,2,3,4,5,6)"
Sqlresponse sqlRspnse = service.Query.Sql(sql).Execute();
I have tried ReplaceRowsMediaUpload and ReplaceRowsMediaUpload directly from the TableResource class without luck.
Calling the upload function from the service object doesn't error out, but I'm not sure what to do next that would actually replace the rows in the Fusion Table (service is a FusiontablesService):
StreamReader str = new StreamReader(Server.MapPath("~") + #"\sample2.csv");
service.Table.ReplaceRows("1X7JMLFy75uq20UnU6cLrGTTDfp6lLuD1Fc3vYYjQ", str.BaseStream, "text/csv").Upload();
I've tried:
service.Table.ReplaceRows("1X7JMLFy75uq20UnU6cLrGTTDfp6lLuD1Fc3vYYjQ").Execute()
following the upload, but this just puts the Fusion table in "stuck" mode.
Can someone please provide the lines required to make ReplaceRows work? (Explanations would be appreciated, but aren't necessary!).
You should change "text/csv" for "application/octet-stream". (See accepted MIME type here: https://developers.google.com/fusiontables/docs/v2/reference/table/replaceRows)
StreamReader str = new StreamReader(Server.MapPath("~") + #"\sample2.csv");
service.Table.ReplaceRows("1X7JMLFy75uq20UnU6cLrGTTDfp6lLuD1Fc3vYYjQ", str.BaseStream, "application/octet-stream").Upload();
The call to Upload should be enough.
Also, try to create a new table to test it out, to be sure it is setup correctly.
You can use a REST API call to replace a row in your Google Fusion table directly instead of writing methods to do that. Here is an example:
POST https://www.googleapis.com/upload/fusiontables/v2/tables/tableId/replace
Please refer to this document for more details, it has a testing environment tool too.

Get Facebook Status from Fan Page using API

I've been trying to get the most recent Facebook Status for a fan page via the API for a while now and can't seem to get what I'm after. I'm really trying to avoid using RSS for it. I can get the full list from the feed via https://graph.facebook.com/174690270761/feed but I want only the last status posted by the page admin, not by anyone else.
Is their an easy way to get it without having to authenticate?
Thanks in advance
edit:
https://graph.facebook.com/174690270761/statuses seems to be what I'm looking for but I need an OAuthAccessToken for this but can't see how to without involving the user, as I'm trying to access through my own credentials/application
Facebook has changed the api and now requires you to provide an access token.
You can use Facebooks PHP sdk for that but i found a much quicker way to go:
<?
$appid = '1234567890';
$secret = 'db19c5379c7d5b0c79c7f05dd46da66c';
$pageid = 'Google';
$token = file_get_contents('https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id='.$appid.'&client_secret='.$secret);
$feed = file_get_contents('https://graph.facebook.com/'.$pageid.'/feed&'.$token);
print_r(json_decode($feed));
?>
Update 15/12/12
app access tokens nosist of the id and secret now - use this request:
$feed = file_get_contents('https://graph.facebook.com/Saxity/feed?access_token='.$appid.'|'.$secret);
I finally found out that this doesn't have to be done through the API, or require any authentication at all.
Basically you can access the data via a JSON feed:
$pageID = "ID of Page" //supply the Id of the fan page you want to access
$url = "https://graph.facebook.com/". $pageID ."/feed";
$json = file_get_contents($url);
$jsonData = json_decode($json);
foreach($jsonData->data as $val) {
if($val->from->id == $pageID) { //find the first matching post/status by a fan page admin
$message = $val->message;
echo $message;
break; //stop looping on most recent status posted by page admin
}
}
I don't think there's a good way to do this. You can process the JSON pretty easily though from the looks of it. You can limit the number of results by using the since query parameter. For instance:
https://graph.facebook.com/174690270761/feed?since=last%20Monday
You can also use limit on that, but I don't think that filters by user. If the administrator is the only one allowed to post, then you may be able to get away with using limit=1.