cocos2dx集成友盟社会化分享

appid对了 , key也对了,为什么就是分享不成功呢,我日!


找了2天,发现,尼玛,原来CCApp.java里面也有做设置平台信息的配置, 原来这里的appid appkey 不对。 改了这里,就分享成功了。日。


public class CCApp extends Application{
    {
        PlatformConfig.setWeixin("wx4111c4b9d895d423", "20d56bf6cf8a11a40f4adafa6929f484");
        PlatformConfig.setSinaWeibo("3921700954","04b48b094faeb16683c32669824ebdad");
        PlatformConfig.setYixin("yxc0614e80c9304c11b0391514d09f13bf");
        PlatformConfig.setLaiwang("laiwangd497e70d4", "d497e70d4c3e4efeab1381476bac4c5e");
        PlatformConfig.setQQZone("100424461", "c7394704798a158208a74ab30104f0ba");
        PlatformConfig.setTwitter("3aIN7fuF685MuZ7jtXkQxalyi", "MK6FEYG63eWcpDFgRYw4w9puJhzDl0tyuqWjZ3M7XJuuG7mMbO");
    }
}




#include "stdafx.h"
#include "LuaMgr.h"
#include "CustomNode.h"
#include "LuaCsbLoader.h"
#include "Cocos2dx/Common/CCUMSocialSDK.h"
#include "Cocos2dx/ShareButton/UMShareButton.h"
#include "LuaUMengShare.h"

USING_NS_CC;

// ʹ???????????ռ?
USING_NS_UM_SOCIAL;

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

/*
 * ?????ص?, ?ûص?????ij?????ij?Ա?????? ????һ????ͨ?ĺ???, ????ʹ?òο?HelloWorldScene??????
* @param platform Ҫ????????Ŀ??ƽ̨
 * @param stCode ??????, 200?????????ɹ?, 100??????ʼ????
 * @param errorMsg ????ʧ??ʱ?Ĵ?????Ϣ,androidƽ̨û?д?????Ϣ
 */
void shareCallback(int platform, int stCode, string& errorMsg)
{
    if ( stCode == 100 )
    {
    	XLOG("####111111111111111111111111111111111111111 ??ʼ????    %d.", stCode);
    }
    else if ( stCode == 200 )
    {
    	XLOG("####2222222222222222222222222222222222222222 ?????ɹ?    %d.", stCode);
    }
    else
    {
    	XLOG("####333333333333333333333333333333333333333333 ????????    %d.", stCode);
    }

    XLOG("############################################platform num is : %d.", platform);
}

IMPL_LUA_CLASS_BEGIN(LuaUMengShare)
    EXPORT_LUA_FUNCTION(LuaAddUMengShare)
IMPL_LUA_CLASS_END()

int LuaUMengShare::LuaAddUMengShare(lua_State* L)
{
	//const char* url = luaL_checkstring(L, 1);
	if (init())
		return 0;
	else
		return 1;
}

bool LuaUMengShare::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }

    // ??????????ť, ????1Ϊ??ť?????????µ?ͼƬ, ????2Ϊ??ťѡ??ʱ??ͼƬ,????3Ϊ????appkey, ????4Ϊ?????ص?
    UMShareButton *shareButton = UMShareButton::create("img/mole/weixin.png","img/mole/weixin.png", "56f8da28e0f************e3", share_selector(shareCallback));
    // ??ʾ?????˷????????ϵ?ƽ̨
    vector<int>* platforms = new vector<int>();
//    platforms->push_back(SINA);
//    platforms->push_back(RENREN);
//    platforms->push_back(DOUBAN);
    platforms->push_back(QZONE);
    platforms->push_back(QQ);
    platforms->push_back(WEIXIN);
    platforms->push_back(WEIXIN_CIRCLE);
    // ???????˷???????????ʾ??ƽ̨
    shareButton->setPlatforms(platforms);
    // ?????ı?????????
    shareButton->setShareContent("umeng social cocos2d-x sdk.") ;
    // ????Ҫ??????ͼƬ, ͼƬ֧?ֱ???ͼƬ??urlͼƬ, ????urlͼƬ??????http://????https://??ͷ
    //shareButton->setShareImage("img/mole/weixin.png") ;
    // ???ð?ť??λ??
    shareButton->setPosition(ccp(150, 180));
    CCMenu* pMenu = CCMenu::create(shareButton, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);


    // ********************** ????ƽ̨??Ϣ ***************************
    CCUMSocialSDK *sdk = shareButton->getSocialSDK();
    sdk->setQQAppIdAndAppKey("11052*6505", "ErGT3*VLqxgaOjQ3");
    sdk->setWeiXinAppInfo("wx4111c4b9****5d429", "20d56bf*****a11a40f4adafa6929f482");
    // ?????û?????һ??ͼ?ķ???ʱ?û???ת????Ŀ??ҳ??, һ??Ϊapp??ҳ????????ҳ??
    // -- 注意, 这个文件要用utf-8的格式打开哦,否则中文分享会乱码,甚至导致游戏闪退!
    sdk->setPlatformShareContent(QQ, "换实物奖品哦~~", "http://c.csdnimg.cn/www/images/ali.png", "无聊?吧~", "http://www.cocos.com/");
    sdk->setPlatformShareContent(QZONE, "兑换实物奖品哦~~", "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png", "无聊?~", "http://www.cocos.com/");
    sdk->setPlatformShareContent(WEIXIN, "实物奖品哦~~", "http://c.csdnimg.cn/www/images/ali.png", "无聊?~", "http://www.cocos.com/");
    sdk->setPlatformShareContent(WEIXIN_CIRCLE, "实物奖品哦~~", "http://c.csdnimg.cn/www/images/ali.png", "无聊?~", "http://www.cocos.com/");
    
    // ?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值