function getPostLink($post_text) { $src = ''; $target = ''; $tag = '<a>'; $tag_end = '</a>'; if (($pos_start = themerex_strpos($post_text, themerex_substr($tag, 0, -1) . ' ')) !== false) { $pos_end = themerex_strpos($post_text, themerex_substr($tag, -1), $pos_start); $pos_end2 = themerex_strpos($post_text, $tag_end, $pos_end); $tag_text = themerex_substr($post_text, $pos_start, ($pos_end2 !== false ? $pos_end2 + 7 : $pos_end) - $pos_start + 1); $src = getTagAttrib($tag_text, $tag, 'href'); $target = getTagAttrib($tag_text, $tag, 'target'); } if ($src == '') { $src = getFirstURL($post_text); } return array('url' => $src, 'target' => $target); }
<?php require dirname(__FILE__) . '/dbConnection.php'; // for dbconnection require dirname(__FILE__) . '/insertData.php'; // for inserting data into the data basae require dirname(__FILE__) . '/firstUrl.php'; // for getting first URL // this is generated token by flipkart affiliate site(https://affiliate.flipkart.com/), // needed to access flipkart product feed api. // usually this token is valid for only 10 hours from the time its generated. // to know more about how to access flipkart pruduct feed api.. please visit https://affiliate.flipkart.com/. $token = "36be5803fee3409eb6440919742e1af3"; $user = "******"; $url = getFirstURL($token); echo $url; // die(); // $url = ""; $tot = 500; for ($i = 0; $i < $tot; $i++) { // Initialize cURL session $ch = curl_init($url); // Option to Return the Result, rather than just true/false curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // setting headers curl_setopt($ch, CURLOPT_HTTPHEADER, array('Fk-Affiliate-Id: ' . $user, 'Fk-Affiliate-Token: ' . $token)); // Perform the request, and save content to $result $result = curl_exec($ch); // print_r($result); if ($result === FALSE) {