shareSDK微信分享图片url识别失败

例:
图片链接 浏览器中可以打开,但使用shareSDK分享的时候,报错:

shareSDK微信分享图片url识别失败_第1张图片
IMG_2798.jpg

打印出的log:

shareWechat: {
    item =     (
                {
            icon = "http://cim-cms.image.alimmdn.com/天信新闻专用/404896306163411419.png";
            summary = "xxxxxxxx";
            title = "\U6709\U6001\U5ea6\Uff0c\U4e0d\U72ec\U884c\U6709\U6001\U5ea6\Uff0c\U4e0d\U72ec\U884c\U6709\U6001\U5ea6\Uff0c\U4e0d\U72ec\U884c\U6709\U6001\U5ea6\Uff0c\U4e0d\U72ec\U884c\U6709\U6001\U5ea6\Uff0c\U4e0d\U72ec\U884c\U6709\U6001\U5ea6";
            url = "http://cmsdev2.cttq.com/tx/c/2017-01-09/499937.shtml";
        }
    );
}

icon图片链接明明是有的,但是却报错-->此图片链接它不识别。

处理方法:
对url进行urlEncode 。

- (NSString *)URLEncodedStringWithStr:(NSString *)str
{
    NSString *encodedString = (NSString *)
    CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                              (CFStringRef)str,
                                                              (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]",
                                                              NULL,
                                                              kCFStringEncodingUTF8));
    return encodedString;
}

使用:

icon = [self URLEncodedStringWithStr:icon];
shareSDK微信分享图片url识别失败_第2张图片
屏幕快照 2017-02-20 15.53.30.png

你可能感兴趣的:(shareSDK微信分享图片url识别失败)