拼多多推广位备案方法(2021.5.5)

拼多多推广位备案方法(2021.5.5)

需求

因为pdd需要给推广位做备案
https://jinbao.pinduoduo.com/qa-system?questionId=204
不然无法转链

<?php
date_default_timezone_set('Asia/Shanghai');

function getPddApi()
{
 
    $client_secret= 'xxxx';//https://open.pinduoduo.com/application/app/list 应用信息中查看
    $param['client_id'] = 'xxxx';//同上
	$param['type'] = 'pdd.ddk.rp.prom.url.generate';
    $param['timestamp'] = getMillisecond();
	$param['channel_type']=10;
	$param['custom_parameters']='{"uid":"xxxx"}';//https://jinbao.pinduoduo.com/user-center/info 多多客ID
	$param['p_id_list']='["xxxx"]';//https://jinbao.pinduoduo.com/promoter-audit 对应pid
    ksort($param);    //  排序
    $str = '';      //  拼接的字符串
    foreach ($param as $k => $v) $str .= $k . $v;
    $sign = strtoupper(md5($client_secret. $str . $client_secret));    //  生成签名    MD5加密转大写
    $param['sign'] = $sign;
    $url = 'http://gw-api.pinduoduo.com/api/router';
    return curl_post($url, $param);
}
 
//  post请求
function curl_post($url, $curlPost)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
 
 
function getMillisecond() {
    list($microsecond , $time) = explode(' ', microtime()); //' '中间是一个空格
    return (float)sprintf('%.0f',(floatval($microsecond)+floatval($time))*1000);
}
echo getPddApi();

?>

注意

在使用转链api时需要传入custom_parameters
在这里插入图片描述

参考链接

https://open.pinduoduo.com/application/document/api?id=pdd.ddk.rp.prom.url.generate
https://jinbao.pinduoduo.com/qa-system?questionId=218

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值