Facebook ads - Products feed - Multiple shipping zones setting - facebook-feed

I'm writing a feed from an e-shop, to give to facebook.
So far so good. The feed is in XML format, and the reference provides a sample, and the format for the shipping field in the item, within the feed, is:
<g:shipping>
<g:country>UK</g:country>
<g:service>Standard</g:service>
<g:price>4.95 GBP</g:price>
</g:shipping>
However, the reference states that the format should be a comma-separated string, like this:
Blob with different prices for each country and region.
Different regions are comma-separated.
The format should be COUNTRY:STATE:SHIPPING_TYPE:PRICE.
e.g.
US:CA:Ground:9.99 USD, US:NY:Air:15.99 USD
Do you catch the contradiction?
If I try in my feed:
<g:shipping>US:CA:Ground:9.99 USD, US:NY:Air:15.99 USD</g:shipping>
I get errors, that country or price is missing.
So, I will have to stick to the sample.
The question is:
Which is the right way to provide multiple shipping zones in the feed?
The debugging tool here is not helping at all...
Do I repeat the g:shipping fieldset?
<g:shipping>
<g:country>UK</g:country>
<g:service>Standard</g:service>
<g:price>4.95 GBP</g:price>
</g:shipping>
<g:shipping>
<g:country>US</g:country>
<g:service>Standard</g:service>
<g:price>5.30 GBP</g:price>
</g:shipping>
Do I iterate within the fieldset?
<g:shipping>
<g:country>UK</g:country>
<g:service>Standard</g:service>
<g:price>4.95 GBP</g:price>
<g:country>US</g:country>
<g:service>Standard</g:service>
<g:price>5.30 GBP</g:price>
</g:shipping>
Or what, if anything, do I have to do to have multiple zones, before switching to CSV (which I don't want to do, but I will if I have to: CSV supports the comma-separated format for multiple zones)?

I'm answering this here for future reference.
The template used by Facebook is the one provided by Google Merchant Center.
As stated here
Include the optional sub-attributes if you need them.
To specify a shipping cost for different delivery locations,
submit multiple shipping attributes including the relevant sub-attributes.
<g:shipping>
<g:country>US</g:country>
<g:region>MA</g:region>
<g:service>Ground</g:service>
<g:price>6.49 USD</g:price>
</g:shipping>
<g:shipping>
<g:country>US</g:country>
<g:region>MA</g:region>
<g:service>Express</g:service>
<g:price>15.99 USD</g:price>
</g:shipping>

For anyone gets warnings about shipping_price_value, shipping_price;
If you are using php and SimpleXMLElement add xmlns:g: to define xml namespace otherwise facebook throws warnings.
Interestingly this only affects shipping fields.
$shipping = $item->addChild('xmlns:g:shipping');
$shipping->addChild('xmlns:g:country', 'TR');
$shipping->addChild('xmlns:g:service', 'Karayolu');
$shipping->addChild('xmlns:g:price', '14.90 TRY');

Related

extract text from documents like PAN and Aadhaar

I am using cloud google vision API to extract text from Aadhaar and PAN. How can I get exact user details like name, father's name, and address?
Raw Data
ଭାରତ ସରକାର
Government of India
ଜିତ୍ୟାନନ୍ଦ ଖେମୁକୁ
NITYANANDA KHEMUDU
ପିତା : ସୀତାରାମ ଖେମୁକୁ
Father: Sitaram Khemudu
ଜନ୍ମ ତାରିଖ / DOB : 01.07.1999
ପୁରୁଷ / Male
ମୋ ଆଧାର, ମୋ ପରିଚୟ
I have built 5-6 OCR till date like aadhar, pan, ITR, Driving Linces etc., using google cloud vision API, I think you are looking for response like
{"pan_card_no":"ECXXXXXX123",
"name":"fshksj"
}
to get such response you need to built your own logic, here are some logic's i can share with you
Perform OCR on your document using Google_cloud_vision API and store that response into one array (Goggle gives logic line by line)
Like in above case if you want to grab DOB first you can build logic like i) if "DOB" in (list of item) then grab the numeric values
To get the name what you can do is dropping the unnecessary items from list by if using if condition like (if "India" in i) or (if i.isdigit()) then drop it likewise you can drop the unnesseary items from main list to get the Name
to grab the Address what you can do is, 95% of the time address come with pincode at last, so what you can do is treat pincode as a last index of address and look of "Address" kind of keyword then add all the elements from "Add keyword index" to "pincode index" ( this can be easily done in list) to validate whether the pincode is valid or not you can use library like Pyzipin
There are multiple conditions that you can use, above are the very basic one i mentioned, if you need any specific logic then then you can ask me

Twitter Premium API Profile location operators profile_country: and profile_region: not working

I am using premium account (not sandbox) for data collection.
I want to collect:
All tweets in English that contain ‘china’ or ‘chinese’ that are user geolocated to US and not geolocated at tweet level, excluding all retweets
All tweets in English that contain ‘china’ or ‘chinese’ that are user geolocated to ‘Minnesota’ and not geolocated at tweet level, excluding all retweets
The code is as follows:
premium_search_args = load_credentials('twitter_API.yaml',
yaml_key ='search_tweets_premium_api', env_overwrite=False)
# keywords for the search
# key word 1
keywords = '(China OR Chinese) lang:en profile_country:US -place_country:US -is:retweet'
# key word 2
keywords = '(China OR Chinese) lang:en -place_country:US profile_region:"Minnesota" -is:retweet'
# define search rule
rule = gen_rule_payload(keywords,from_date='2019-12-01',
to_date='2019-12-10',results_per_call=500)
# create result stream and print before start
rs = ResultStream(rule_payload=rule, max_results=1250000,
**premium_search_args)
My problems are that:
For the first one, a large portion of the results I get didn’t satisfy the query. First, some don’t have Profile Geo enrichment, i.e. user.derived.locations attribute is not in the user object. Second, if it is, a lot don’t have country code US, i.e. they are identified to other countries.
For the second one, the result I get from this method is a smaller subset of the results I can get from 1). That is, when I filter all tweets user geolocated to Minnesota (by user.derived.locations.region) from profile_country:US, it gives a larger sample than using profile_region:“Minnesota”. A considerable amount of data is missing using this method.
I have tried several times but it seems that user geolocation operators don’t work exactly what I want. Does anyone has any idea why this is the case? I would very much appreciate any answers/suggestions/comments.
Thank you!

Matching an element in a column, to others in the same column

I have columns taken from excel as a dataframe, the columns are as follows:
HolidayTourProvider|Packages|Meals|Accommodation|LocalTravelVehicle|Cancellationfee
Holiday Tour Provider has a couple of company names
Packages, the features provided in each package are mostly the same like
Meals,Accommodation etc... even though one company may call it "Saver", others may call it "Budget". (each of column mostly follow Yes/No, except Local travel vehicle are again car names like Ford Taurus,jeep cherokee etc..
Cancellation amount is integers)
I need to write a function like
match(HolidayTP,Package)
where the user can give input like
match(AdventureLife, Luxury)
then I need to return all the packages that have similar features with Luxury by other Holiday Tour Providers, no matter what name they give the package like 'Semi Lux', 'Comfort' etc...
I want to give a counter for every match and display all the packages that exceed the counter by 3 or 4.
This is my first python code. I am stuck here.
fb is the total df I exported to
def mapHol(HTP, PACKAGE):
mfb = (fb['HTP']== HTP)&(fb['package']== package)
B = fb[mfb]
for i in fb[i]:
for j in B[j]:
if fb[i]==B[j]:
count+=1
I dont know how to proceed, please help me this is my first major project, I started on my own.

DAX / Xetra on alphavantage

I am very very happy with Alphavantage.
BUT I can't find the german stocks (Xetra)
I have tried:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=xtr:lin&apikey=MYKEY
(But this works https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=NYSE:DIN&apikey=MYKEY)
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=Lin.be&apikey=MYKEY
(But this works: https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=Novo-b.CO&apikey=MYKEY)
So my question is - has anyone had any luck getting german stocks on Alphavanta (or another free service. Realtime is not crucial, but obviously a plus).
I use the "Search Endpoint" function to find german stocks on alphavantage.
Let's say you look for "BASF" you could query:
https://www.alphavantage.co/query?function=SYMBOL_SEARCH&keywords=BASF&apikey=[your API key]&datatype=csv
You get a list with possible matches:
symbol,name,type,region,marketOpen,marketClose,timezone,currency,matchScore
BASFY,BASF SE,Equity,United States,09:30,16:00,UTC-05,USD,0.8889
BFFAF,BASF SE,Equity,United States,09:30,16:00,UTC-05,USD,0.8889
BASFX,BMO Short Tax-Free Fund Class A,Mutual Fund,United States,09:30,16:00,UTC- 05,USD,0.8889
BAS.DEX,BASF SE,Equity,XETRA,08:00,20:00,UTC+02,EUR,0.7273
BAS.FRK,BASF SE,Equity,Frankfurt,08:00,20:00,UTC+02,EUR,0.7273
BASA.DEX,BASF SE,Equity,XETRA,08:00,20:00,UTC+02,EUR,0.7273
BAS.BER,BASF SE NA O.N.,Equity,Berlin,08:00,20:00,UTC+02,EUR,0.7273
BASF.NSE,BASF India Limited,Equity,India/NSE,09:15,15:30,UTC+5.5,INR,0.6000
See documentation: https://www.alphavantage.co/documentation/
It seems to work with the yahoo symbols on alphavantage, at least for a few stocks (I did not check all). BASF for example works with:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=BASF.TI&apikey=MYKEY
The alphavantage symbols for German securities consist of the Xetra symbol + .DE. For example EUNL.DE (for iShares MSCI World Core ETF). You can find a list of all Xetra stocks here.

eBay API aspectFilter with MaxPrice parameter returns 0 results

I am using the following URL to fetch car listing. But when I add the MaxPrice parameter It shows 0 items. But on the site there are 12 items that have price below my value.
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.12.0&SERVICE-NAME=FindingService&SECURITY-APPNAME=prosoftda-d112-4c99-9bec-8a09c902a7a&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=50&categoryId=6001&outputSelector=PictureURLSuperSize&REST-PAYLOAD=true
&aspectFilter(0).aspectName=Make&aspectFilter(0).aspectValueName=Audi
&aspectFilter(1).aspectName=Model&aspectFilter(1).aspectValueName=Q7
&aspectFilter(2).aspectName=Model+Year&aspectFilter(2).aspectValueName=2013
&aspectFilter(3).aspectName=MaxPrice&aspectFilter(3).aspectValueName=50000.00
When I remove MaxPrice parameter the URL works perfectly.
Btw, I got the solution for this question:
To pass the price value need to pass as ItemFilter. not with the AspectFilter.
I replace the string :
&aspectFilter(3).aspectName=MaxPrice&aspectFilter(3).aspectValueName=50000.00
By the string :
&itemFilter(0).name=MaxPrice&itemFilter(0).value=500000.00
So It works now. As Price parameter is related to attribute so need to pass with the ItemFilter.
So final URL Is:
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.12.0&SERVICE-NAME=FindingService&SECURITY-APPNAME=prosoftda-d112-4c99-9bec-8a09c902a7a&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=50&categoryId=6001&outputSelector=PictureURLSuperSize&REST-PAYLOAD=true
&aspectFilter(0).aspectName=Make&aspectFilter(0).aspectValueName=Audi
&aspectFilter(1).aspectName=Model&aspectFilter(1).aspectValueName=Q7
&aspectFilter(2).aspectName=Model+Year&aspectFilter(2).aspectValueName=2013
&itemFilter(0).name=MaxPrice&itemFilter(0).value=500000.00
Thanks. may be this can help someone who is finding the same question.
I have no experience with this API so this is just a shot in the dark. But I found this link:
http://developer.ebay.com/DevZone/finding/CallRef/findItemsAdvanced.html
From what Ive read within that MaxPrice is more of an "itemFilter" (things such as maxPrice, bestOfferOnly, featuredSeller) than an "aspectFilter" (things such as Make, Model, Optical Zoom).
Further down it also states that some itemFilters need a paramName, such as maxPrice
For example, if you use the MaxPrice itemFilter, you will need to specify
a parameter Name of Currency with a parameter Value that specifies the type
of currency desired.
Again never used this API but seems relevant to me.