Skip to content

Instantly share code, notes, and snippets.

@pzzrudlf
Created September 28, 2016 07:56
Show Gist options
  • Save pzzrudlf/adca285f5803baf2149a1f446967635a to your computer and use it in GitHub Desktop.
Save pzzrudlf/adca285f5803baf2149a1f446967635a to your computer and use it in GitHub Desktop.
<?php
/**
*将参与淘客计划的商品id转换为淘客链接
*
*$param version 0.1
*
*$author pzzrulf <[email protected]>
*
*/
function get_word($html,$star,$end){
$pat = '/'.$star.'(.*?)'.$end.'/s';
if(!preg_match_all($pat, $html, $mat)) {
}else{
$wd= $mat[1][0];
}
return $wd;
}
function convertTbkUrl($num_id, $pid, $cookie)
{
$zym_19 = $cookie;
$zym_20 = array(' ',' ','' . "\xa" . '','' . "\xd" . '','' . "\x9" . '');
$zym_24 = array("","","","","");
$zym_19 = str_replace($zym_20, $zym_24, $zym_19);
$zym_23 = get_word($zym_19,'_tb_token_=',';');
$zym_22 = get_word($zym_19,'t=',';');
$zym_21 = get_word($zym_19,'cna=',';');
$zym_13 = get_word($zym_19,'l=',';');
$zym_12 = get_word($zym_19,'mm-guidance3',';');
$zym_5 = get_word($zym_19,'_umdata=',';');
$zym_4 = get_word($zym_19,'cookie2=',';');
$zym_3 = get_word($zym_19,'cookie32=',';');
$zym_1 = get_word($zym_19,'cookie31=',';');
$zym_2 = get_word($zym_19,'alimamapwag=',';');
$zym_6 = get_word($zym_19,'login=',';');
$zym_7 = get_word($zym_19,'alimamapw=',';');
$zym_11 = 't='.$zym_22.';cna='.$zym_21.';l='.$zym_13.';mm-guidance3='.$zym_12.';_umdata='.$zym_5.';cookie2='.$zym_4.';_tb_token_='.$zym_23.';v=0;cookie32='.$zym_3.';cookie31='.$zym_1.';alimamapwag='.$zym_2.';login='.$zym_6.';alimamapw='.$zym_7;
$zym_10 =microtime(true)*1000;
$zym_10 = explode('.', $zym_10);
$zym_29 = $pid;
$zym_27 = explode('_',$zym_29);
$zym_28 = $zym_27[2];
$zym_32 = $zym_27[3];
// $zym_31 = get_client_ip();
$zym_31 = "127.0.0.1";
$zym_30 = '50_'.$zym_31.'_15881_1468693605455';
$zym_33 = 'http://pub.alimama.com/common/code/getAuctionCode.json?auctionid='.$num_id.'&adzoneid='.$zym_32.'&siteid='.$zym_28.'&t='.$zym_10[0].'&pvid='.$zym_30.'&_tb_token_='.$zym_23.'&_input_charset=utf-8';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $zym_33);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.alimama.com/index.htm');
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Cookie:{'.$zym_11.'}', ));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$rs = curl_exec($ch);
curl_close($ch);
return json_decode($rs,true);
}
/**
*这是加入淘客计划的商品id
*/
$num_id = "";
/**
*这是你的pid
*/
$pid = "";
/**
*这是你的阿里妈妈的cookie
*/
$cookie = "";
echo "<pre>";
print_r(convertTbkUrl($num_id, $pid, $cookie));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment