Error 403 - sharing post&photo


#1

I’m trying to do api that will share my short post and photo. I’m getting this error:
You are trying to load data from a www stream which had the following error when downloading.
403 Forbidden
UnityEngine.WWW:get_text()

I’m doing it in Unity. When I was sharing only text - it was working. When I changed a code to share media - I don’t know why it stopped work. That’s fragment of my code:

 Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("status", text);
			parameters.Add ("media[]", texture);
			Debug.Log(parameters);
            // Add data to the form to post.
            WWWForm form = new WWWForm();
            form.AddField("status", text);
			form.AddField("media[]", texture);
            // HTTP header
            var headers = new Hashtable();
            headers["Authorization"] = GetHeaderWithAccessToken("POST", PostTweetURL, consumerKey, consumerSecret, response, parameters);


           	WWW web = new WWW(PostTweetURL, form.data, headers);
            yield return web;

            if (!string.IsNullOrEmpty(web.error))
            {
				Debug.Log(string.Format("PostTweet - failed. {0}\n{1}", web.error, web.text));
				callback(false);
            }

I’m basing on this http://stevenyau.wordpress.com/2013/12/26/working-with-twitter-api-1-1-with-unity/

I don’t have authorization mistakes etc, everything works, I’m getting tokens etc. I just have ERROR403. I have chosen all permissions - it didn’t help. Any ideas? I’m trying to do it since week and I completely lost ideas.


#2

If you are adding media to your tweet, you will need to use a different URL endpoint (upload) to the one that you would use just for text (statuses/update). What is PostTweetURL set to, and have you modified the code to deal with this?


#3

My PostTweetURL is: https://api.twitter.com/1.1/statuses/update_with_media.json So I think it’s right?


#4

That does look right, although that endpoint is now deprecated and replaced with the two stage upload, then update.

I’m not familiar with the original Unity code so I’m afraid I can’t comment on what else might need to be changed. Maybe the original blog author can help here?


#5

Actually everything looks good (I found result in comments: http://stevenyau.wordpress.com/2013/12/26/working-with-twitter-api-1-1-with-unity/comment-page-1/#comment-176) but I’m getting code 195. I read anywhere that’s because I’m in Poland. Is it true? It means that I can’t share photo from Poland with your sdk?
Mistake sounds: PostTweet – failed.

{"errors":[{"code":195,"message":"Missing or invalid url parameter."}]}

#6

I am not aware of any issue with posting images from specific countries, what have you read on this?