Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Pinterest嵌入按钮_C#_Asp.net_Pinterest - Fatal编程技术网

C# Pinterest嵌入按钮

C# Pinterest嵌入按钮,c#,asp.net,pinterest,C#,Asp.net,Pinterest,我的ASP.NET应用程序有一个Pinterest嵌入按钮,在我单击Pin按钮后,该按钮不会捕获预览图像,并向我显示如下错误消息: Parameter 'image_url' (value http:///Resources/Uploads/21622d3e-b865-49c4-bf22-155562ed2978.jpg) is not a valid URL format. 有人能看一下我用来生成按钮的代码,看看我在这里是否做错了什么吗 PinterestEmbedButton.Text

我的ASP.NET应用程序有一个Pinterest嵌入按钮,在我单击Pin按钮后,该按钮不会捕获预览图像,并向我显示如下错误消息:

Parameter 'image_url' 
(value http:///Resources/Uploads/21622d3e-b865-49c4-bf22-155562ed2978.jpg) 
is not a valid URL format.
有人能看一下我用来生成按钮的代码,看看我在这里是否做错了什么吗

PinterestEmbedButton.Text = String.Format("<a data-pin-config=\"none\" 
href=\"//pinterest.com/pin/create/button/?url={0}&media={1}&description={2}\" 
data-pin-do=\"buttonPin\" >
<img src=\"//assets.pinterest.com/images/pidgets/pin_it_button.png\" /></a>",
System.Web.HttpUtility.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri), 
"Resources/Uploads/" + product.Images.FirstOrDefault().Image.LargeFileName, 
product.Name);

如果你点击
1
,你会看到它没有拉取图像,点击
固定它
会给出我上面提到的错误信息

我已尝试将代码更改为:

PinterestEmbedButton.Text = String.Format("<a data-pin-config=\"none\" href=\"//pinterest.com/pin/create/button/?url={0}&media={0}/{1}&description={2}\" data-pin-do=\"buttonPin\" ><img src=\"//assets.pinterest.com/images/pidgets/pin_it_button.png\" /></a>", System.Web.HttpUtility.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri), "Resources/Uploads/" + product.Images.FirstOrDefault().Image.LargeFileName, product.Name); but it still won't pull up an image and now I get the error 'Whoops! This is not a valid image.' Closer, though.
PinterestEmbedButton.Text=String.Format(“,System.Web.HttpUtility.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri)”,“Resources/Uploads/”+product.Images.FirstOrDefault().Image.LargeFileName,product.Name);但它仍然无法提取图像,现在我得到了错误“哎呀!这不是一个有效的图像。不过,请靠近一点。

过去,我在Wordpress网站上的各种社交媒体按钮(原始代码而非Wordpress插件)中遇到过类似的挑战。10次中有9次是源代码的问题。一个快速的破解/修复方法是从源代码抓取图像,将其上传到您的Web服务器,并将代码引用到您的Web服务器上的图像目录,而不是Pintrest的站点。

为了时间起见,我将Pin it按钮从ASP.NET文本更改为javascript。我从这篇文章中得到了javascript:它似乎工作得很好。谢谢大家的帮助

您需要图像的完整url,包括域(例如
http://www.knueppels.com/Resources/Uploads/21622d3e-b865-49c4-bf22-155562ed2978.jpg
)中的
媒体
参数。我已编辑了您的标题。请参阅“”,其中的共识是“不,他们不应该”。我编辑了原始帖子,显示我在url中的
媒体
参数中添加了{0}/{1}。这使得它成为
www.knueppels.com/Resources/Uploads
或我正在运行的任何站点。这是一个好主意,但是这个图像在我们的服务器上。代码引用了uploads文件夹。我被难住了我想知道Pinterest最近是否做了一些改变,因为它过去工作得很好。如果他们有开发人员资源或开发人员的联系人,我会利用这些资源。很可能他们上传了一些代码,在幕后破坏了一些东西,他们甚至没有意识到。好主意。我会看看我能从Pinterest那里得到什么
PinterestEmbedButton.Text = String.Format("<a data-pin-config=\"none\" href=\"//pinterest.com/pin/create/button/?url={0}&media={0}/{1}&description={2}\" data-pin-do=\"buttonPin\" ><img src=\"//assets.pinterest.com/images/pidgets/pin_it_button.png\" /></a>", System.Web.HttpUtility.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri), "Resources/Uploads/" + product.Images.FirstOrDefault().Image.LargeFileName, product.Name); but it still won't pull up an image and now I get the error 'Whoops! This is not a valid image.' Closer, though.