Asked  7 Months ago    Answers:  5   Viewed   34 times

i am using http://api.easyjquery.com/ips/?ip=115.119.253.90&full=true this api for getting current location but when this site goes down i am not able to get current location.

can google provide any api to find current location using ip.

 Answers

36

If you don't want to use the HTML5 Geolocoation API, you can detect a bit from IP.

Or try other other solution

The Google Geocoding API

Geolocator-PHP

Maxmind http://www.maxmind.com/app/php

ipinfodb

Wednesday, March 31, 2021
 
braindamage
answered 7 Months ago
37

the solution of this question is

  <?php
                    $url = str_replace(' ','-',$sport['title']);
                    $url = str_replace(":",'',$url);
                    $url = str_replace("'",'',$url);    
                ?>


<a href="<?php echo base_url().'news/readmore/'.$sport['id']."/".urlencode($url);?>"><?php echo $sport_top['title'];?></a>
Wednesday, March 31, 2021
 
macha
answered 7 Months ago
74

Modify your function to send header of JSON_DATA in post request

function sendPostData($url, $post){
 $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");  
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: ' . strlen($post))                                                                       
   );  
  $result = curl_exec($ch);
  curl_close($ch);  // Seems like good practice
  return $result;
}

In file use

<?php

$json_input_data=json_decode(file_get_contents('php://input'),TRUE);

print_r( $json_input_data);


?>

As everyone said there is no need of $str_data = json_encode($data);,Since data is already in json.

Wednesday, March 31, 2021
 
Domiik
answered 7 Months ago
29

Make sure that you have added the service account as an Owner in Google Search Console as described here: https://developers.google.com/search/apis/indexing-api/v3/prereqs#verify-site.

My problem was that we had multiple entries for the domain in the Search Console (with and without www and with and without https); after adding the service account as an owner to all 4 entries it's working.

Wednesday, March 31, 2021
 
Classified
answered 7 Months ago
19

The Google Contacts API uses an Atom feed. The contacts are provided as entry elements. So it makes more sense the iterate them. To do that you have to register a prefix for the atom namespace as well.

$document = new DOMDocument();
$document->loadXml($xml);
$xpath = new DOMXpath($document);
$xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
$xpath->registerNamespace('gd', 'http://schemas.google.com/g/2005');

If you use DOMXpath::evaluate() you can use expressions that return scalars. The second argument is a context node for the expression.

foreach ($xpath->evaluate('/atom:feed/atom:entry') as $entry) {
  $contact = [
    'name' => $xpath->evaluate('string(atom:title)', $entry),
    'image' => $xpath->evaluate('string(atom:link[@rel="http://schemas.google.com/contacts/2008/rel#photo"]/@href)', $entry),
    'emails' => [],
    'numbers' => []
  ];
  foreach ($xpath->evaluate('gd:email', $entry) as $email) {
    $contact['emails'][] = $email->getAttribute('address');
  }
  foreach ($xpath->evaluate('gd:phoneNumber', $entry) as $number) {
    $contact['numbers'][] = trim($number->textContent);
  }
  var_dump($contact);
}

With the first example response from the Google Contacts API documentation this returns:

array(3) {
  ["name"]=>
  string(17) "Fitzwilliam Darcy"
  ["image"]=>
  string(64) "https://www.google.com/m8/feeds/photos/media/userEmail/contactId"
  ["email"]=>
  string(0) ""
  ["numbers"]=>
  array(1) {
    [0]=>
    string(3) "456"
  }
}

The example does not include an email element, so it is empty. A contact can have multiple email addresses and/or phone numbers or none at all. The rel attribute is provided to classify them as home, work, ...

Fetching the image:

The image is provided as an Atom link element with a specific rel attribute.

atom:link[@rel="http://schemas.google.com/contacts/2008/rel#photo"]

This would return the link node, but it is possible to fetch the href attribute directly:

atom:link[@rel="http://schemas.google.com/contacts/2008/rel#photo"]/@href

Cast the attribute node list into a string:

string(atom:link[@rel="http://schemas.google.com/contacts/2008/rel#photo"]/@href)

Wednesday, March 31, 2021
 
jerrygarciuh
answered 7 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :