Search code examples
phpwordpressyellow-pages

Is there a way to get Jamaica Yellow Pages to show search results on my website?


I've been searching for quite a while on how can you view search results based on a PHP form on a client's site pulling the data from Jamaican Yellow Pages.

I've found APIs for the Canadian one (http://www.yellowapi.com/), but nothing else.

I've tried using a URL with the search parameters to redirect to the Yellow Pages results page, but obviously with no luck, something like the following:

<form action="http://jamaicayp.com/Jamaica-Kingston/<?php $_GET['what']?>" 
    method="GET" class="form-input">
    <input type="text" name="what" placeholder="sometext"/>
    <input type="submit" name="some_name" value="Find"/>
</form>

Any help would be appreciated.


Solution

  • It is only possible if the Jamaican Yellow Pages allow API. Otherwise you can only link people to the website. Example:

    <?php
    $what = $_POST['what'];
    $what = urlencode($what);
    ?>
    <form action="http://jamaicayp.com/Jamaica-Kingston/<?php echo $what;?>" method="POST">
    <input type="text" name="what" placeholder="sometext"/>
    <input type="submit" name="some_name" value="Find"/>
    </form>
    

    urlencode is necessary for the search to contain spaces. Invalid link: something.com/search/this is bad link Good link: something.com/search/this%20is%20good%20link