Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by seblondres

  1. Thanks for taking the time to answer my question. I have tried


    but unfortunately it still doesn't picking up the merchant logo url while I don't have any problems to get to the other child nodes.

  2. Hi,


    I have this code below to retrieve the products from the XML further down, I can get to any children but the Merchant logo URL. If someone could please let me know how to reach the Merchant logo URL.

    foreach ($productsResult->Products->Product as $result) {
        echo "<a href=".$result->Offer->Url." target='_blank'><img class='productImg' src=".$result->Offer->Images[0]->Image->Url."/></a>"; 
        echo "<p><b class='price'>£".$result->Offer->Price->Price."</b></p><br>";
        echo "<p><img src=".$result->Offer->Merchant[0]->Name->Logo->Url."/></p>"; // This is where I need help
        echo "<p class='title'>".$result->Offer->Title.".</p><a class='goToStore w3-btn w3-blue' href=".$result->Offer->Url." target='_blank'><b>Visit Store</b></a>";
       <Description> </Description>
        <Image available="true">
         <Url>The URL I need</Url>


  3. Hi,


    I have this script below which select random keywords from a file:

    $search = explode("\n", file_get_contents('keywords.txt'));
    $search[ array_rand($search) ]; 

    Now I want to randomly pass those keywords in an URL so I can $_Get them e.g. http://example.com/index.php?keyword={A random keyword from my text file}


    If someone could point me to the right direction.


    Many Thanks,

  4. Hi,


    I'm trying to detect whether <totalresults> = 0 from the Indeed API.


    Here is the code I'm using:

    $search ='oihhb';           
    $xml = simplexml_load_file('http://api.indeed.com/ads/apisearch?publisher=xxxxxx&q='.$search.'&l=&sort=&radius=&st=&jt=&start='.$start.'&limit=1&fromage=&filter=&latlong=1&co=fr&chnl=&userip=');
    foreach($xml->results->result as $result)
           if ($xml->totalresults == 0) {
             echo 'empty';   } else   { 
         echo $xml->totalresults;

    As you can see from the code above, I'm searching for $search ='oihhb'; which purposely doesn't return any results - see <query> below:

    <response version="2">

    So I want to do, it's to echo 'empty' if <totalresults> = 0 but I can't get it work i.e. I can't print 'empty'. However I have to say that I can print the total number of results: echo $xml->totalresults;


    So must be something wrong with if ($xml->totalresults == 0).


    If someone could point me to the right direction.


    Many Thanks,

  5. Got it, thanks!


    <?phpinclude_once 'simple_html_dom.php';$search_term = array( "lyon", "cannes", "paris", "marseille" );for($i=0;$i<count($search_term);$i++){  $city = $search_term[$i];  $url = "http://www.pole-emploi.fr/annuaire/?TypeServices=0&VilleLieu={$city}&annusearch=1&Chercher=Chercher";$html = file_get_html($url);$ret =  $html->find('div[class=Annuaire-int]');foreach($ret as $story)    echo $story;}?>
  6. I've tried the following but I can only display the information for Paris:


    <?phpinclude_once 'simple_html_dom.php';$search_term = array( "lyon", "cannes", "paris" ); foreach ($search_term as $search_term) {   $url = "http://www.pole-emploi.fr/annuaire/?TypeServices=0&VilleLieu={$search_term}&annusearch=1&Chercher=Chercher";}$html = file_get_html($url);$ret =  $html->find('div[class=Annuaire-int]');foreach($ret as $story)    echo $story;?>
  7. Hi,


    I have the script below which works fine when searching 1 term (city). Now what I like to do, it's to search through multiple terms, so how can I pass one term after the other into the $url so I can get the result for each term on the same page. Ideally I'd like to be able to read a txt file with all the terms (cities).

    <?phpinclude_once 'simple_html_dom.php';$search_term = "paris";$url = "http://www.domain.net/annuaire/?TypeServices=0&VilleLieu={$search_term}&annusearch=1&Chercher=Chercher";$html = file_get_html($url);$ret =  $html->find('div[class=Annuaire-int]');foreach($ret as $story)    echo $story;?>



  8. Thanks for your answers:


    The variable $url would be used to scrape this page for example: http://www.test2.com/directory/london-greenwich


    Here is how it should works:

    1. I'm on the index page and I have a link http:/test1.com/directory.php?city=london-greenwich

    2. When I click on the link above I'm redirected to directory.php which contain the php file above with the variable $city = $_GET['city'];

    3. With this variable $city = $_GET['city']; I should be able to get "london-greenwich"

    4. Then I want to add that piece of url "london-greenwich" to $url = "http://www.test2.com/directory/"

    5. So I can build the following url $url = "http://www.test2.com/directory/london-greenwich"



  9. Hi,


    I'm trying to build a url in the php file below from a url in the browser.


    URL in the browser: http:/test1.com/directory.php?city=london


    then I like to get the city and add it at the end of the url in the php file below so it looks like that: http://www.test2.com/directory/london


    so far I go this but I can only access http://www.test2.com/directory/

    <?php$city = $_GET['city'];$fields = array('city' => $city);$url = "http://www.test2.com/directory/". http_build_query($fields, '');?>

    Thanks for your help,


  10. Hi,


    I'd like to add a spinner to my ajax call below.


    <script>var setOffset = 0;var URL = "https://partner-int-api.groupon.com/deals.json";var countryCode = "UK";var token = "&tsToken=UK_AFF_0_201236_212556_0";var categoryFilter = "bars-et-restaurants";var limit = 12;var jsonCallBack = "&callback=jsonp";function calljsonp(offset){var ajaxURL = URL + "?country_code=" + countryCode + token + "&filters=category:" + categoryFilter + "&offset=" + offset + "&limit=" + limit + jsonCallBack;var script = document.createElement("script");script.setAttribute("src", ajaxURL);document.body.appendChild(script);document.body.removeChild(script); }function jsonp(Obj){$.each(Obj.deals, function(i,data)   {var div = document.createElement("div"); div.className = 'img';    var img = document.createElement("span"); img.innerHTML = ("<a href='"+data.dealUrl+"'target='_blank'><img src='"+data.smallImageUrl+"'></a>");var h4 = document.createElement("h4"); h4.innerHTML = ("<div class='titleDesc'><a href='"+data.dealUrl+"'target='_blank'>"+data.shortAnnouncementTitle+"</a></div>");    var desc = document.createElement("p"); desc.innerHTML = ("<div class='feedDesc'>"+data.merchant.name+", <span id='nc'>"+data.locations[0].city+"</span><br><br>    <b>Valeur : </b><span style='text-decoration: line-through;'>"+data.options[0].value.formattedAmount+"</span><br>    <b>Prix promo : </b><span style='color:#FF8600;'><b>"+data.options[0].price.formattedAmount+"</b>    (-"+data.options[0].discountPercent+"%)</span><br>Déjà <span style='color:#DD0057;'><b>"+data.soldQuantityMessage+"</b></span> acheteur(s),<br>il reste <span style='color:#8AC007;'><b>"+data.options[0].remainingQuantity+"</b></span> offre(s).</div>");        div.appendChild(img);div.appendChild(h4);div.appendChild(desc);document.getElementById("showdata").appendChild(div);      });//$("<hr />").appendTo("#showdata");setOffset = setOffset + limit;}function more(){calljsonp(setOffset);  }calljsonp(setOffset);</script>


    I have this piece of code, but I'm not sure where to implement it?

    $.ajax({// your ajax codebeforeSend: function(){$('.loader').show()},complete: function(){$('.loader').hide();}});

    Many thanks,


  11. Hi,


    I've been using the Groupon API, see feed below. I can access without any problem "+data.highlightsHtml+" but I'm struggling to access some other data such as deals > options > value > formattedAmount


    I've tried this for example: "+data.options.value.formattedAmount+" but I got the following error: Uncaught TypeError: Cannot read property 'formattedAmount' of undefined


    So my question is, how can I access formattedAmount from value?


    URL: https://partner-int-api.groupon.com/deals.json?country_code=uk&tsToken=IE_AFF_0_201236_212556_0&division_id=london&offset=0&limit=20

    {"deals": [{"id": "bistro-casbah-2-50348338","title": "Mezze Lunch For Two With Tea for £8.95 at Bistro Casbah (50% Off)","status": "open","type": "groupon","dealUrl": "http://t.groupon.ie/r?tsToken=IE_AFF_0_201236_212556_0&url=http%3A%2F%2Fwww.groupon.co.uk%2Fdeals%2Fdealbank_en_gb%2Fbistro-casbah-2%2F50348338%3FCID%3DIE_AFF_5600_225_5383_1%26nlp%26utm_medium%3Dafl%26utm_source%3DGPN%26utm_campaign%3D201236%26mediaId%3D212556","startAt": "2014-11-23T00:00:00Z","endAt": "2015-01-26T23:59:59Z","smallImageUrl": "http://static.uk.groupon-content.net/80/31/1416592073180.jpg","mediumImageUrl": "http://static.uk.groupon-content.net/50/31/1416592073150.jpg","largeImageUrl": "http://static.uk.groupon-content.net/28/31/1416592073128.jpg","sidebarImageUrl": "http://static.uk.groupon-content.net/80/31/1416592073180.jpg","grid4ImageUrl": "http://static.uk.groupon-content.net/50/31/1416592073150.jpg","grid6ImageUrl": "http://static.uk.groupon-content.net/28/31/1416592073128.jpg","placeholderUrl": "http://assets2.grouponcdn.com/images/groupon/grayPlaceholder.png","highlightsHtml": "<p>Chefs prepare Moroccan and Algerian cuisine to authentic recipes at this colourful restaurant located on Regents Park Road</p>","pitchHtml": "<h2>The Deal</h2>nn<ul>n  <li>n    <p>A large platter for two people <em>(usually £12.95)</em></p>n  </li>n  <li>n    <p>Includes tabbouleh, feta salad, homemade hummus and freshly cooked falafel</p>n  </li>n  <li>n    <p>Served with bread</p>n  </li>n  <li>n    <p>Includes pot of mint tea each <em>(£2.50)</em></p>n  </li>n</ul>nn<h2>The Merchant</h2>n<p>Alive with colour and spice, <a href="http://bistrocasbah.co.uk/">Bistro Cashbah</a> serves North African cuisine in Finchley. The kitchen prepares Algerian and Moroccan dishes according to traditional recipes while fare is complemented by authentic coffee and mint tea. The restaurant features candlelight, a host of African artwork and trinkets and shisha pipes available for hire.</p>","shortAnnouncementTitle": "Mezze Lunch For Two With Tea","announcementTitle": "Mezze Lunch For Two With Tea","newsletterTitle": "Mezze Lunch For Two With Tea","placementPriority": "side-deal","shippingAddressRequired": false,"isTipped": true,"tippingPoint": 1,"isSoldOut": false,"soldQuantity": 5,"soldQuantityMessage": "5","isInventoryDeal": false,"isGiftable": true,"options": [{"id": 50348338,"soldQuantity": 5,"soldQuantityMessage": "5","minimumPurchaseQuantity": 1,"maximumPurchaseQuantity": 2,"discountPercent": 50,"initialQuantity": 1560,"remainingQuantity": 1555,"limitedQuantityRemaining": 1555,"isSoldOut": false,"isLimitedQuantity": true,"title": "Mezze Lunch for 2 with a Moroccan tea","expiresAt": "2015-02-25T23:59:59Z","endAt": "2015-01-26T23:59:59Z","buyUrl": "https://www.groupon.co.uk/deals/bistro-casbah-2-50348338/confirmation?pledge_id=50348338","externalUrl": "","discount": {"amount": 880,"formattedAmount": "£8.80","currencyCode": "GBP"},"price": {"amount": 895,"formattedAmount": "£8.95","currencyCode": "GBP"},"value": {"amount": 1775,"formattedAmount": "£17.75","currencyCode": "GBP"},"tax": {"amount": 0,"formattedAmount": "£0.00","currencyCode": "GBP"},


  12. ok, I have slice up the URL so now I have a variable for offset. How can I increase offset +10 from a button or link?




    <script>$(document).ready(function() {var URL = "https://partner-int-api.groupon.com/deals.json";var countryCode = "UK";var token = "&tsToken=IE_AFF_0_202176_212556_0";var categoryFilter = "category:food-and-drink";var offset = "0";var limit = "10";var jsonCallBack = "&callback=?";var ajaxURL = URL + "?country_code=" + countryCode + token + "&filters=" + categoryFilter + "&offset=" + offset + "&limit=" + limit + jsonCallBack;$.getJSON(ajaxURL,function(data) {$.each(data.deals, function(i,data) {var div_data ="<div><a href='"+data.dealUrl+"'>"+data.title+"</a><p>"+data.highlightsHtml+"</p></div>";$(div_data).appendTo("#showdata");}); // end each}); // end get JSON}); // end ready</script>


  • Create New...