php code to find city,state and country name using pincode - php

Is there any API or anything which provides city,state and country name when pincode is given.Please share if you have any solution
Thanks in Advance

Hello. there are many more sites which provides this kind of
information i will show you two of them.
Third Party API
Google API
try this url with your pincode. this will gives you data in json format like below one. i have removed some of data to show you so it was not exactly as per return response of third party api.
{
"Message": "Number of Post office(s) found: 1",
"Status": "Success",
"PostOffice": [
{
"Name": "I E Bapunagar",
"Description": "",
"BranchType": "Sub Post Office",
"DeliveryStatus": "Delivery",
"Taluk": "Ahmadabad City",
"Circle": "Ahmadabad City",
"District": "Ahmedabad",
"Division": "Ahmedabad City",
"Region": "Ahmedabad HQ",
"State": "Gujarat",
"Country": "India"
}
]
}
check it, and if you want any help,you can ask.

Use the GeoCoding API
For example, to lookup zip 626134 use a request like this:
http://maps.googleapis.com/maps/api/geocode/json?address=626134&sensor=true

Related

Paypal PAYOUT_NOT_AVAILABLE

My sandbox account return this error when creating a payout
{
"name": "PAYOUT_NOT_AVAILABLE",
"message": "You live in a country that is not allowed to send this payout.",
}
This error is not listed in https://developer.paypal.com/docs/api/payments.payouts-batch/#errors
The account is configured in México (MX) and the official documentation includes MX in the payouts docs.
Am I missing something? Can't find any doc that excludes specific countries.
Just some exceptions for Argentina, Brazil and Malaysia.
It also defiens Mexican currency in the features
https://developer.paypal.com/docs/payouts/#payouts-features
I happened to find a similar endpoint but the weird thing is that it's not listed in the main APIs menu but it seems to be working, for reference check:
https://developer.paypal.com/docs/payouts/test
Update: it seems to be related to the test data that's used in the note field, even if using batch payouts the following changed the result status:
{
"sender_batch_header": {
"sender_batch_id": "Payouts_2018_100007",
"email_subject": "You have a payout!",
"email_message": "You have received a payout! Thanks for using our service!"
},
"items":[
{
"recipient_type": "EMAIL",
"amount": {
"value": "500",
"currency": "MXN"
},
"note": "POSPYO001",
"sender_item_id": "201403140001",
"receiver": "ss36#business.example.com",
"alternate_notification_method": {
"phone": {
"country_code": "52",
"national_number": "4491110560"
}
},
"notification_language": "sp-SP"
}
]
}
A single payout looks like this:
{
"sender_payout_header":
{
"sender_batch_id": "1524086406556",
"email_subject": "This email is related to simulation"
},
"items": [
{
"recipient_type": "EMAIL",
"receiver": "payouts-simulator-receiver#paypal.com",
"note": "POSPYO001",
"sender_item_id": "15240864065560",
"amount":
{
"currency": "USD",
"value": "1.00"
}
}]
}
I was having the same issue and it was because my country(India) name is present in supported countries list of PayPal but i got to know about PayPal Commerce Platform availability where it is not supporting India. Check below link
https://developer.paypal.com/docs/api/reference/country-codes/?mark=countries#paypal-commerce-platform-availability
My work is only on sandbox account of paypal for testing so i simply created new test account of country US.
Possibly your paypal account is from any country listed in above link. Please check country of your main paypal account.

ajax call that returns json file

im trying to figure out what the easiest way would be. i have a to do an api call for data i get a json file in return but im trying to parse the data to php so that my website would just pull from the database. do i have to create all the same fields that the api call is using for instance name gender age height. and then do i name it something else so i can call from my webpage. because in order to get a nfl player it gives me a 16 digit code and i want it just to be say tom brady
i have used javascript to pull the data but dont know what to do from there
"players": [{
"name": "Kyle Rudolph",
"jersey": "82",
"last_name": "Rudolph",
"first_name": "Kyle",
"abbr_name": "K.Rudolph",
"preferred_name": "Kyle",
"birth_date": "1989-11-09",
"weight": 265.0,
"height": 78,
"status": "A01",
"id": "1059e9dc-97df-4643-9116-883a0573d8b1",
"position": "TE",
"birth_place": "Cincinnati, OH, USA",
"high_school": "Elder (OH)",
"college": "Notre Dame",
"college_conf": "Independent",
"rookie_year": 2011,
"draft": {
"year": 2011,
"round": 2,
"number": 43,
"team": {
"name": "Vikings",
"market": "Minnesota",
"alias": "MIN",
"id": "33405046-04ee-4058-a950-d606f8c30852"
}
},
John, you don't have to use the same names. Once your PHP receives data from the API, parse it into whatever names you want, ignore the values you don't need etc... For example, suppose the API gives you a first and last name, but in your database you only care about full name. As another example, if the API gives you player weight in pounds but you need it in kilograms:
$api_result = file_get_contents($url);
$api_data = json_decode($api_result);
$name = "$api_data->last, $api_data->first"
$weight = $api_data->weight * 0.454; //convert pounds to kg for storage
Now you can store $name and $weight in your DB as you like. When your website pulls data from your backend, the shape of the data produced by the API doesn't matter because you stored it in the shape that is most helpful to your application

Contact creation through Graph API producing "Object reference not set to an instance of an object."

I've been using the Graph API for contact creation and synchronization between a master account and all of our organization's Office 365 accounts. This has been working well up until the past month or so.
My synchronization process involves querying a specific folder of the master account for contacts, caching them, and then running through the list of target users, creating contacts where necessary. Getting lists of contacts, creating contact folders, and deleting contacts all still works as expected. Creating a contact returns "ErrorInternalServerError: Object reference not set to an instance of an object."
I have been using the client_credentials flow and checked that my app has the appropriate credentials in the Azure AD admin panel. Below is the JSON object that I'm POSTing for contact creation. This is happening regardless of contact, or target user.
{
"categories": [],
"birthday": null,
"fileAs": "GPS 00 Bob, Todd",
"displayName": "GPS 00 Bob, Todd",
"givenName": "Todd",
"initials": "T.G.0.B.",
"middleName": "",
"nickName": null,
"surname": "GPS 00 Bob",
"title": "",
"yomiGivenName": null,
"yomiSurname": null,
"yomiCompanyName": null,
"generation": "",
"emailAddresses": [
{
"name": "Email",
"address": "todd.bob#contactsyncing.com"
}
],
"imAddresses": [
""
],
"jobTitle": "Chief Financial Officer",
"companyName": "",
"department": "",
"officeLocation": null,
"profession": null,
"businessHomePage": null,
"assistantName": null,
"manager": null,
"homePhones": [
""
],
"mobilePhone": "",
"businessPhones": [
""
],
"homeAddress": {
"street": "",
"city": "",
"state": "",
"countryOrRegion": "",
"postalCode": ""
},
"businessAddress": {
"street": "701 East Lumbar Ave",
"city": "Minot",
"state": "ND",
"countryOrRegion": "United States of America",
"postalCode": "68745"
},
"otherAddress": {},
"spouseName": null,
"personalNotes": null,
"children": []
}
edit
Additional information: I am posting to a specific contact folder with its ID. Here is an example of the URL: https://graph.microsoft.com/v1.0/users/91bbdb7b-3b41-474c-93c9-99b1da960c18/contactFolders/AAMkADFlNzQ5NGQ5LTEwNjYtNGFiZS04NDlhLTViOGE0YzMzZjI3OQAuAAAAAAA9YtgrncHYSKObisZl7JkCAQChpNwDV4FXRaJC6UF1HyyuAAAAAAFFAAA=/contacts
Is that contactFolder ID properly formed?
/edit
The script is written in PHP and I'm simply cURLing these requests. Any thoughts are suggestions would be greatly appreciated. Let me know if any other information would be helpful.
Thanks!
After filtering down contact fields to a bare minimum and then re-adding them one by one, I've found that the birthday field was at fault. It seems that the Graph API no longer accepts a null value for this. Removing the field completely if a birthday is not specified seems to have resolved the issue.
I consider this resolved. Perhaps the Graph API documentation should be updated to reflect this fact? Additionally, it would seem prudent to improve the API's response to this error. "InternalServerError" does not adequately describe the cause.
Thanks!

How can i fetch page data from graph with only pageid

I have a problem with graph api.
The call "https://graph.facebook.com/[pageID]" fails with the message
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
I need the full url of the facebook-page. Is there a way to get the url of a page from pageid only?
EDIT: Thank you for tips. The error was, that when the page is not public, that i cannot query infos via graph. Its also not working, when i (admin of page!) call the graph-url...
If you take a look at Page Graph API Reference there is a example url to get information about the page, include the url of the page that you want. The example url request is :
https://graph.facebook.com/19292868552
and the result is :
{
"about": "Grow your app with Facebook\nhttps://developers.facebook.com/ ",
"company_overview": "Facebook Platform enables anyone to build social apps on Facebook, mobile, and the web.\n\n",
"is_published": true,
"talking_about_count": 34563,
"username": "FacebookDevelopers",
"website": "http://developers.facebook.com",
"were_here_count": 0,
"category": "Product/service",
"id": "19292868552",
"name": "Facebook Developers",
"link": "http://www.facebook.com/FacebookDevelopers",
"likes": 1187896,
"cover": {
"cover_id": "10151298218353553",
"source": "http://sphotos-b.ak.fbcdn.net/hphotos-ak-ash4/s720x720/377655_10151298218353553_500025775_n.png",
"offset_y": 0,
"offset_x": 0
}
}
I think in your problem you put the wrong page ID.

How do i show the maps for the venue while creating an event programmatically with the PHP SDK?

When i create an event with the graph api i need to specify the venue and i would like also to show the map.
I do
$fb_event['name'] = "THis is to test latitude";
$fb_event['description'] = "And longitude!!!!";
$fb_event['start_time'] = date( "c", Ai1ec_Facebook_Event::get_facebook_start_time($event->start));
$fb_event['location'] = "Where you want";
$fb_event['street'] = "Via andrea del sarto 9";
$fb_event['city'] = "Milan";
$fb_event['latitude'] = 45.444975793404;
$fb_event['longitude'] = 9.2119209654715;
$facebook = $this->facebook_instance_factory();
try {
$result = $facebook->api( "/me/events", "POST", $fb_event );
} catch (FacebookApiException $e) {
fb($e);
}
This produce this event which show the correct street and city, but no map. If i edit the event and save, the map "Magically" appears using the street and city correctly.
In any case latitude and longitude are ignored.
What am i doing wrong?
If you compare your two test events in the Graph API explorer you'll see that Event ID 239298922846828 does not have its latitude and longitude populated, while 245655182207213 does. I'm assuming 245655182207213 is an event you've edited.
Looking at your code, you seem to be doing everything as described in the documentation. However, I've found that what is described does not always work.
What I've been seeing is that events populated from within Facebook that occur at a known venue are no longer allowing you to specify an address. Instead all they save is a venue id within Facebook which you can then drill into to get the address, etc.
Take a look at one of my events. For this event, there is no way to edit the details of this location from within Facebook, nor does the event venue details get returned with an API call. I'm using the API to pull the event details to an external website. This change caused me days of frustration.
I started seeing this behavior in late April. I haven't found any official documentation announcing this change.
When some documentation appears, what I expect the new event venue workflow will be is something like:
Query the area where your event will take place to see if a venue exists already.
If yes, get save its id.
If not, create a new community page for your venue and save its id.
Use this ID to populate the event venue.
In the end this is a known facebook bug
https://developers.facebook.com/bugs/173095916131752
Two different formats when create using the same parameters.
When create event through gql
{
"id": "xxxxxxxxxxxxxx",
"owner": {
"name": "xxxxxxxxxx",
"id": "xxxxxxxxx"
},
"name": "W1112",
"start_time": "2013-10-22",
"is_date_only": true,
"location": "Tulsa, OK, United States",
"venue": {
"latitude": 36.131388888889,
"longitude": -95.937222222222,
"street": "",
"zip": "",
"id": "109436565740998"
},
"privacy": "SECRET",
"updated_time": "2013-09-19T12:23:26+0000"
}
When create event through fb
{
"id": "xxxxxxxxxxxxxx",
"owner": {
"name": "xxxxxx",
"id": "xxxxxxxx"
},
"name": "1234",
"start_time": "2013-10-09T21:26:00+1100",
"end_time": "2013-10-25T00:26:00+1100",
"timezone": "Australia/Sydney",
"is_date_only": false,
"location": "Maroubra Junction",
"venue": {
"latitude": -33.940804216453,
"longitude": 151.23876752992,
"city": "Maroubra",
"state": "NSW",
"country": "Australia",
"id": "153993547968514",
"street": "832 anzac Parade ",
"zip": "2035"
},
"privacy": "SECRET",
"updated_time": "2013-09-19T10:50:14+0000"
}

Categories